Ticket #8 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

Int truncated to 30 bits on 32-bit systems -- sometimes, at least

Reported by: SamB Owned by:
Priority: major Milestone:
Component: backend Version:
Keywords: Cc:
Test Case: bugs/IntEnum

Description

When running the test bugs/IntEnum, instead of:

[16777215,33554431,50331647,67108863,83886079,100663295,117440511,134217727,150994943,167772159,
184549375,201326591,218103807,234881023,251658239,268435455,285212671,301989887,318767103,
335544319,352321535,369098751,385875967,402653183,419430399,436207615,452984831,469762047,
486539263,503316479,520093695,536870911,553648127,570425343,587202559,603979775,620756991,
637534207,654311423,671088639,687865855,704643071,721420287,738197503,754974719,771751935,
788529151,805306367,822083583,838860799,855638015,872415231,889192447,905969663,922746879,
939524095,956301311,973078527,989855743,1006632959,1023410175,1040187391,1056964607,1073741823,
1090519039,1107296255,1124073471,1140850687,1157627903,1174405119,1191182335,1207959551,
1224736767,1241513983,1258291199,1275068415,1291845631,1308622847,1325400063,1342177279,
1358954495,1375731711,1392508927,1409286143,1426063359,1442840575,1459617791,1476395007,
1493172223,1509949439,1526726655,1543503871,1560281087,1577058303,1593835519,1610612735,
1627389951,1644167167,1660944383,1677721599,1694498815,1711276031,1728053247,1744830463,
1761607679,1778384895,1795162111,1811939327,1828716543,1845493759,1862270975,1879048191,
1895825407,1912602623,1929379839,1946157055,1962934271,1979711487,1996488703,2013265919,
2030043135,2046820351,2063597567,2080374783,2097151999,2113929215,2130706431,2147483647]

I get:

[16777215,33554431,50331647,67108863,83886079,100663295,117440511,134217727,150994943,167772159,
184549375,201326591,218103807,234881023,251658239,268435455,285212671,301989887,318767103,
335544319,352321535,369098751,385875967,402653183,419430399,436207615,452984831,469762047,
486539263,503316479,520093695,536870911,-520093697,-503316481,-486539265,-469762049,-452984833,
-436207617,-419430401,-402653185,-385875969,-369098753,-352321537,-335544321,-318767105,
-301989889,-285212673,-268435457,-251658241,-234881025,-218103809,-201326593,-184549377,
-167772161,-150994945,-134217729,-117440513,-100663297,-83886081,-67108865,-50331649,-33554433,
-16777217,-1,16777215,33554431,50331647,67108863,83886079,100663295,117440511,134217727,
150994943,167772159,184549375,201326591,218103807,234881023,251658239,268435455,285212671,
301989887,318767103,335544319,352321535,369098751,385875967,402653183,419430399,436207615,
452984831,469762047,486539263,503316479,520093695,536870911,-520093697,-503316481,-486539265,
-469762049,-452984833,-436207617,-419430401,-402653185,-385875969,-369098753,-352321537,
-335544321,-318767105,-301989889,-285212673,-268435457,-251658241,-234881025,-218103809,
-201326593,-184549377,-167772161,-150994945,-134217729,-117440513,-100663297,-83886081,
-67108865,-50331649,-33554433,-16777217,-1,16777215,33554431,50331647,67108863,83886079,
100663295,117440511,134217727,150994943,167772159,184549375,201326591,218103807,234881023,
251658239,268435455,285212671,301989887,318767103,335544319,352321535,369098751,385875967,
402653183,419430399,436207615,452984831,469762047,486539263,503316479,520093695,536870911,
-520093697,-503316481,-486539265,-469762049,-452984833,-436207617,-419430401,-402653185,
-385875969,-369098753,-352321537,-335544321,-318767105,-301989889,-285212673,-268435457,
-251658241,-234881025,-218103809,-201326593,-184549377,-167772161,-150994945,-134217729,
-117440513,-100663297,-83886081,-67108865,-50331649,-33554433,-16777217,-1,16777215,33554431,
50331647,67108863,83886079,100663295,117440511,134217727,150994943,167772159,184549375,201326591,
218103807,234881023,251658239,268435455,285212671,301989887,318767103,335544319,352321535,
369098751,385875967,402653183,419430399,436207615,452984831,469762047,486539263,503316479,
520093695,536870911,-520093697,-503316481,-486539265,-469762049,-452984833,-436207617,-419430401,
-402653185,-385875969,-369098753,-352321537,-335544321,-318767105,-301989889,-285212673,
-268435457,-251658241,-234881025,-218103809,-201326593,-184549377,-167772161,-150994945,
-134217729,-117440513,-100663297,-83886081,-67108865,-50331649,-33554433,-16777217,-1,16777215]

Notice how the numbers wrap around again and again. Running the numbers at the crossover through the handy calculator Python, I get:

>>> map(hex,[536870911,-520093697])
['0x1fffffff', '-0x1f000001']

Attachments

IntEnum_final.grin (8.7 kB) - added by SamB 6 years ago.
The final Grin code I get
IntEnum_code.c (42.9 kB) - added by SamB 6 years ago.
The C code

Change History

Changed 6 years ago by SamB

The final Grin code I get

Changed 6 years ago by SamB

The C code

Changed 6 years ago by Lemmih

$ ./IntEnum 
[16777215,33554431,50331647,67108863,83886079,100663295,117440511,134217727,150994943,167772159,184549375,201326591,218103807,234881023,251658239,268435455,285212671,301989887,318767103,335544319,352321535,369098751,385875967,402653183,419430399,436207615,452984831,469762047,486539263,503316479,520093695,536870911,553648127,570425343,587202559,603979775,620756991,637534207,654311423,671088639,687865855,704643071,721420287,738197503,754974719,771751935,788529151,805306367,822083583,838860799,855638015,872415231,889192447,905969663,922746879,939524095,956301311,973078527,989855743,1006632959,1023410175,1040187391,1056964607,1073741823,1090519039,1107296255,1124073471,1140850687,1157627903,1174405119,1191182335,1207959551,1224736767,1241513983,1258291199,1275068415,1291845631,1308622847,1325400063,1342177279,1358954495,1375731711,1392508927,1409286143,1426063359,1442840575,1459617791,1476395007,1493172223,1509949439,1526726655,1543503871,1560281087,1577058303,1593835519,1610612735,1627389951,1644167167,1660944383,1677721599,1694498815,1711276031,1728053247,1744830463,1761607679,1778384895,1795162111,1811939327,1828716543,1845493759,1862270975,1879048191,1895825407,1912602623,1929379839,1946157055,1962934271,1979711487,1996488703,2013265919,2030043135,2046820351,2063597567,2080374783,2097151999,2113929215,2130706431,2147483647,-2130706433,-2113929217,-2097152001,-2080374785,-2063597569,-2046820353,-2030043137,-2013265921,-1996488705,-1979711489,-1962934273,-1946157057,-1929379841,-1912602625,-1895825409,-1879048193,-1862270977,-1845493761,-1828716545,-1811939329,-1795162113,-1778384897,-1761607681,-1744830465,-1728053249,-1711276033,-1694498817,-1677721601,-1660944385,-1644167169,-1627389953,-1610612737,-1593835521,-1577058305,-1560281089,-1543503873,-1526726657,-1509949441,-1493172225,-1476395009,-1459617793,-1442840577,-1426063361,-1409286145,-1392508929,-1375731713,-1358954497,-1342177281,-1325400065,-1308622849,-1291845633,-1275068417,-1258291201,-1241513985,-1224736769,-1207959553,-1191182337,-1174405121,-1157627905,-1140850689,-1124073473,-1107296257,-1090519041,-1073741825,-1056964609,-1040187393,-1023410177,-1006632961,-989855745,-973078529,-956301313,-939524097,-922746881,-905969665,-889192449,-872415233,-855638017,-838860801,-822083585,-805306369,-788529153,-771751937,-754974721,-738197505,-721420289,-704643073,-687865857,-671088641,-654311425,-637534209,-620756993,-603979777,-587202561,-570425345,-553648129,-536870913,-520093697,-503316481,-486539265,-469762049,-452984833,-436207617,-419430401,-402653185,-385875969,-369098753,-352321537,-335544321,-318767105,-301989889,-285212673,-268435457,-251658241,-234881025,-218103809,-201326593,-184549377,-167772161,-150994945,-134217729,-117440513,-100663297,-83886081,-67108865,-50331649,-33554433,-16777217,-1,16777215]

Changed 6 years ago by SamB

  • status changed from new to closed
  • resolution set to fixed
  • component changed from unspecified to backend
Note: See TracTickets for help on using tickets.