xsharp.eu • Float, Real8, or Decimal? - Page 5
Page 5 of 5

Float, Real8, or Decimal?

Posted: Tue Dec 01, 2020 10:37 pm
by Chris
Hi Otto,

Yes, VO always treats floating point literals as FLOAT, so I am pretty sure the whole comparison is done with FLOAT rules, not with REAL8 ones. You should get the same results also in X#, if the project option /vo14 (Use FLOAT literals) is enabled.

Float, Real8, or Decimal?

Posted: Thu Dec 03, 2020 8:57 pm
by Otto
I've tested the /vo14 on an individual case and it looks good!
Now we are going to test it in bulk. I'll hope next week to see the outcome.

Thanks for all your prompt responses and patience. These are stressful times for us here.

Float, Real8, or Decimal?

Posted: Thu Dec 03, 2020 10:50 pm
by Chris
Great to hear it works for you Otto! For projects moved from VO, there's no reason really ever having /vo14 disabled, at least in the first stages, since it is providing compatible behavior with the code in VO.

And you can still use REAL8/4 literals when needed, even when /vo14 is enabled, by using the "d" and"s" postfixes:

123.45s : System.Single/REAL4 literal
123.45d : System.Double/REAL8 literal

Float, Real8, or Decimal?

Posted: Fri Dec 04, 2020 2:29 pm
by ArneOrtlinghaus
We are also working with /VO14 float literals enabled and we left float var definitions where float were.

Originally we were thinking about converting to Real8. But in the programs there are too many comparisons like f == 0 .or. f <> 0 that are hard to find.

There were very few cases where we had to change something in Dotnet in comparison to VO for getting the same results as before. Dotnet calculates with about 14 digits and VO with about 16. For working with normal business units as currency or quantities there is no problem. There were some places where very small numbers of less than 0.00000001 had to be compared and there we had to adapt the rounding process a little bit.
Ntrim and Str(f) without specifying the exact number of digits gives also different results. But in any case there shouldn't be string conversions without specifying what is really wanted.

Arne