1. power(2,63) is not equal to 9223372036854775808
- Posted by axtens_bruce Feb 13, 2023
- 804 views
- Last edited Feb 14, 2023
Following on from this discussion about the tokeniser's handling of 9223372036854775808:
Euphoria Interpreter v4.1.0 development 64-bit Windows, Using System Memory Revision Date: 2015-02-02 14:18:53, Id: 6300:57179171dbed
print(1, power(2,63) - 9223372036854775808)
Should equal zero, right?
1.844674407e+019So until this is fixed we need to use power(2,63) instead of 9223372036854775808 on those rare occasions
2. Re: power(2,63) is not equal to 9223372036854775808
- Posted by axtens_bruce Feb 14, 2023
- 755 views
Even more interesting
print(1, power(2,63) - 1 = 9223372036854775807) puts(1,"\n") print(1, power(2,63) = 9223372036854775808) puts(1,"\n") print(1, power(2,63) + 1 = 9223372036854775809) puts(1,"\n") print(1, power(2,63) + 2 = 9223372036854775810)
>eui bug.ex 1 0 0 1
3. Re: power(2,63) is not equal to 9223372036854775808
- Posted by jimcbrown (admin) Feb 14, 2023
- 735 views
Would be interesting to see if someone can reproduce this on *nix. Wonder if it's a MinGW bug.
If you have MinGW yourself, you could also try this C program, to see if the bug shows up by itself.
#include <stdio.h> #include <math.h> int main(int argc, char ** argv) { printf("%d\n", (powl(2.0L, 63.0L) - 1.0L) == 9223372036854775807.0L); printf("%d\n", powl(2.0L, 63.0L) == 9223372036854775808.0L); printf("%d\n", (powl(2.0L, 63.0L) + 1.0L) == 9223372036854775809.0L); printf("%d\n", (powl(2.0L, 63.0L) + 2.0L) == 9223372036854775810.0L); printf("%d\n", (pow(2.0, 63.0) - 1.0) == 9223372036854775807.0); printf("%d\n", pow(2.0, 63.0) == 9223372036854775808.0); printf("%d\n", (pow(2.0, 63.0) + 1.0) == 9223372036854775809.0); printf("%d\n", (pow(2.0, 63.0) + 2.0) == 9223372036854775810.0); printf("%d\n", (powl(2.0L, 63.0L) - 1.0L) == 9223372036854775807.0); printf("%d\n", powl(2.0L, 63.0L) == 9223372036854775808.0); printf("%d\n", (powl(2.0L, 63.0L) + 1.0L) == 9223372036854775809.0); printf("%d\n", (powl(2.0L, 63.0L) + 2.0L) == 9223372036854775810.0); return 0; }
4. Re: power(2,63) is not equal to 9223372036854775808
- Posted by irv Feb 14, 2023
- 744 views
Eui (and euc) give the same results on Linux 64 bit:
1 0 0 1
irv@irv-desktop:~$ gcc power.c -o power irv@irv-desktop:~$ ./power 1 1 1 1 1 1 1 1 0 1 0 0 irv@irv-desktop:~$
5. Re: power(2,63) is not equal to 9223372036854775808
- Posted by axtens_bruce Feb 15, 2023
- 701 views
WSLg Jammy on Windows 11
bugmagnet@LAPTOP-H6HBEGA9:/mnt/c/Users/bugma/Dropbox/Projects/exercism-dev/oe$ ./bug 1 1 1 1 1 1 1 1 0 1 0 0
6. Re: power(2,63) is not equal to 9223372036854775808
- Posted by petelomax Feb 16, 2023
- 615 views
- Last edited in March
Just so you know, the four tests in #2 above now seem to work on 64-bit Phix, producing 1,1,1,1, but you may need 1.0.5+