Recently, I am using VB.net for an infinite classification. I suddenly found a precision problem with VB.net. Now I am sending it to my garden to see if you have any ideas or solutions.
Code As follows: String . Format ( " {0 :####################} " , 2 ^ 63 - 1 )
The above is the 63 power of 2 minus the value of 1.
Output result: 9223372036854780000
If the format is not used, the result is: 922337204255478e + 18.
The output of the same sentence in C # is as follows: 9223372036854775807.
The result output by using the calculator provided by Windows is the same as that output by C. This is depressing. Is it true that the precision of VB.net is a problem? Or am I using the wrong method?
Please give us some advice ~
Problem solved
Solution:
Use ctype (math. Pow (2,63)-1, long)
In the project, compile, and advanced compilation options: In which box is optimized, the option "do not check integer overflow" is hooked! OK ~