Doubles has a precision of
53 bits (
Double-precision floating-point format)
so, 2^53-1 = 9'007'199'254'740'991 is the last Quad which fits exactly into a double.
if the quad higher, you will lost last digit(s)
Code: Select all
Debug "accurate:"
For n=-10 To -1
Quad.q = 1<<53+n
Double.d = Quad
Debug Str(Quad)+" vs. "+StrD(Double)
Next
Debug "can be inaccurate:"
For n=0 To 10
Quad.q = 1<<53+n
Double.d = Quad
Debug Str(Quad)+" vs. "+StrD(Double)
Next
accurate:
9007199254740982 vs. 9007199254740982.0000000000
9007199254740983 vs. 9007199254740983.0000000000
9007199254740984 vs. 9007199254740984.0000000000
9007199254740985 vs. 9007199254740985.0000000000
9007199254740986 vs. 9007199254740986.0000000000
9007199254740987 vs. 9007199254740987.0000000000
9007199254740988 vs. 9007199254740988.0000000000
9007199254740989 vs. 9007199254740989.0000000000
9007199254740990 vs. 9007199254740990.0000000000
9007199254740991 vs. 9007199254740991.0000000000
can be inaccurate:
9007199254740992 vs. 9007199254740992.0000000000
9007199254740993 vs. 9007199254740992.0000000000
9007199254740994 vs. 9007199254740994.0000000000
9007199254740995 vs. 9007199254740996.0000000000
9007199254740996 vs. 9007199254740996.0000000000
9007199254740997 vs. 9007199254740996.0000000000
9007199254740998 vs. 9007199254740998.0000000000
9007199254740999 vs. 9007199254741000.0000000000
9007199254741000 vs. 9007199254741000.0000000000
9007199254741001 vs. 9007199254741000.0000000000
9007199254741002 vs. 9007199254741002.0000000000
You can not demand that the "(basic) knowledge" of floating point numbers described in the help for PureBasic.
Same with Long and Quad, will not say anything about the byte order.
Endianness