good afternoon guys
I'm coming back here after detecting an uncomfortable limit in VFP regarding very large numbers and I discover this.
A picture is worth a thousand words
xsharp last public version
visual studio 2019
Best regards
Juan
numeric operation with big numbers
Re: numeric operation with big numbers
Hi Juan,
This is because the result of the multiplication is too large to fit even in an Int64. The maximum positive value that can fit in the 64 bits of such a type is 9,223,372,036,854,775,807,as you can see with
? Int64.MaxValue:ToString()
Your test number of 123,456,789,012,345,678 is already very close to that and multiplying it by 100 makes it go beyond the limit and the result overflows. If you had enabled overflow checking in the project properties, a runtime overflow exception would be thrown.
If you need to use such very large numbers with precision, you can use directly the System.Decimal type, which uses 96 bits for representing a number, so can handle much larger ones than Int64 (but is also much slower).
This is because the result of the multiplication is too large to fit even in an Int64. The maximum positive value that can fit in the 64 bits of such a type is 9,223,372,036,854,775,807,as you can see with
? Int64.MaxValue:ToString()
Your test number of 123,456,789,012,345,678 is already very close to that and multiplying it by 100 makes it go beyond the limit and the result overflows. If you had enabled overflow checking in the project properties, a runtime overflow exception would be thrown.
If you need to use such very large numbers with precision, you can use directly the System.Decimal type, which uses 96 bits for representing a number, so can handle much larger ones than Int64 (but is also much slower).
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu