QB64 Phoenix Edition
double to 2^53 - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2)
+--- Thread: double to 2^53 (/showthread.php?tid=1657)



double to 2^53 - Jack - 05-03-2023

Ok, I know that the size of the mantissa of double is 53 bits, see if you can guess what values will be printed by this snippet

Code: (Select All)
Dim As Double x

x = 9007199254740992 ' 2^53
Print x
x = x + 1#
Print x
x = x + 1#
Print x
Print "================="
x = 9007199254740998
Print x
x = x + 1#
Print x
x = x + 1#
Print x
Print "================="
x = 9999999999999998
Print x
x = x + 1#
Print x



RE: double to 2^53 - SMcNeill - 05-03-2023

53 bits isn't 2 ^ 53.

For example:  2 bits has a limit of 3 (&H11).  8 bits has a limit of 255 (&H11111111).

The limit is number of bits ^ 2 - 1.    (n ^ 2 - 1)


RE: double to 2^53 - Jack - 05-03-2023

hello SMcNeil
I think that you made typo, The limit is number of bits ^ 2 - 1.    (n ^ 2 - 1)
yo probably meant "The limit of number is 2^bits - 1.    (2^n  - 1)" or something like that


RE: double to 2^53 - SMcNeill - 05-03-2023

Aye.  Sorry.   2 ^ n - 1.  I'm trying to get over Covid again, so my brain is half broken atm.  Apologies.


RE: double to 2^53 - Jack - 05-03-2023

I hope that you get well soon Smile