Still number

We encourage new members to introduce themselves here. Get to know one another and share your interests.
Post Reply
User avatar
softdevo@tiscali.it
Posts: 191
Joined: Wed Sep 30, 2015 1:30 pm

Still number

Post 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
Attachments

[The extension viaef has been deactivated and can no longer be displayed.]

img.JPG
img.JPG (15.86 KiB) Viewed 894 times
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Still number

Post 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")
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Karl-Heinz
Posts: 774
Joined: Wed May 17, 2017 8:50 am
Location: Germany

Still number

Post 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
User avatar
Chris
Posts: 4906
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Still number

Post 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.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
User avatar
softdevo@tiscali.it
Posts: 191
Joined: Wed Sep 30, 2015 1:30 pm

Still number

Post by softdevo@tiscali.it »

OK thanks
Danilo
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Still number

Post 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 894 times
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
softdevo@tiscali.it
Posts: 191
Joined: Wed Sep 30, 2015 1:30 pm

Still number

Post 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
User avatar
wriedmann
Posts: 3755
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Still number

Post 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.
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply