xsharp.eu • Still number
Page 1 of 1

Still number

Posted: Mon Mar 25, 2019 3:54 pm
by softdevo@tiscali.it
Taking a cue from what we said in the previous discussion on numbers "If someone can explain it to me?" I did a test.
I don't think it is possible in an application to replace the numerical initialization from System.Double to System.Decimal because the behavior is not identical, see image and a Xide test application.
Danilo

Still number

Posted: Mon Mar 25, 2019 4:07 pm
by Chris
Hi Danilo,

Yeah, when you print a Decimal, you need to specify how many decimal places to include, because it does not contain the extra formatting information that FLOAT has:

LOCAL d AS Decimal
d := 123.1234567
? d:ToString("N2")
d := 12
? d:ToString("N2")

Still number

Posted: Mon Mar 25, 2019 5:32 pm
by Karl-Heinz
Hi Chris,

i think there must have been a problem in the origin 2.0.0.9 build. When i switch back to that version i can confirm what Danilo is seeing. But with the newer dlls i have, the decimal and double output is as expected "8,70" and "870,00". When i change the decimal setting with the origin build to e.g. setdecimal (3), the decimals output is still "9" and "870" , while the doubles are "8,700" and "870,000". With the newer Dlls the output is in both cases "8,700" and "870,000".

regards
Karl-Heinz

Still number

Posted: Mon Mar 25, 2019 5:41 pm
by Chris
Ah, right, thanks Karl-Heinz, Robert made some changes in this area indeed. Can't send new runtime dlls now, as they are in an intermediate state, but we will soon have a new build ready, Danilo please test again when it gets released.

Still number

Posted: Mon Mar 25, 2019 5:55 pm
by softdevo@tiscali.it
OK thanks
Danilo

Still number

Posted: Mon Mar 25, 2019 6:21 pm
by wriedmann
Ciao Danilo,

if you replace the NTrim() function call with the ToString() method call, as follows:

Code: Select all

local cVal as string
local nVal,nVal1 as System.Decimal

cVal := "8.70"

nVal := Val(cVal)
self:oLabel2:Text := nVal:ToString()  // NTrim(nVal)
nVal1 := (nVal*100)
self:oLabel1:Text := nVal1:ToString()	// NTrim(nVal1)
it works as expected:
DecimalNumbers.png
DecimalNumbers.png (2.74 KiB) Viewed 427 times
Wolfgang

Still number

Posted: Mon Mar 25, 2019 6:24 pm
by softdevo@tiscali.it
Yes thank you, but I would have to change thousands of lines of code with the risk of making mistakes that come out only at runtime.
Danilo

Still number

Posted: Mon Mar 25, 2019 6:29 pm
by wriedmann
Hi Danilo,
of course, if you have it used that much!
But when you change all these places to the system.decimal datatype, you have to check it nevertheless, because things that worked previously could give unexpected results (more precise).
Wolfgang
P.S. I'm waiting for the DBFCDX RDD so I can finally move my accounting program (il mio programma di contabilità) and get rid of all the problems that are facing up from time to time.