@@ -35,9 +35,9 @@ local function eq
35(a,b,limit)
35(a,b,limit)
36if not limit then
36if not limit then
37if floatbits >= 50 then
37if floatbits >= 50 then
38−limit=1e-11.0
38+limit=1e-11
40−limit=1e-5.0
40+limit=1e-5
43return a == b or math.abs(a - b) <= limit
43return a == b or math.abs(a - b) <= limit
@@ -67,10 +67,10 @@ local a,b = math.modf(3.5)
67assert(a == 3.0 and b == 0.5)
67assert(a == 3.0 and b == 0.5)
68a,b=math.modf(- 2.5)
68a,b=math.modf(- 2.5)
69assert(a == - 2.0 and b == - 0.5)
69assert(a == - 2.0 and b == - 0.5)
70−a,b=math.modf(- 3e23.0)
70+a,b=math.modf(- 3e23)
71−assert(a == - 3e23.0 and b == 0.0)
71+assert(a == - 3e23 and b == 0.0)
72−a,b=math.modf(3e35.0)
72+a,b=math.modf(3e35)
73−assert(a == 3e35.0 and b == 0.0)
73+assert(a == 3e35 and b == 0.0)
74a,b=math.modf(- 1 / 0)
74a,b=math.modf(- 1 / 0)
75assert(a == - 1 / 0 and b == 0.0)
75assert(a == - 1 / 0 and b == 0.0)
76a,b=math.modf(1 / 0)
76a,b=math.modf(1 / 0)
@@ -82,8 +82,8 @@ assert(eqT(a,3) and eqT(b,0.0))
82a,b=math.modf(minint)
82a,b=math.modf(minint)
83assert(eqT(a,minint) and eqT(b,0.0))
83assert(eqT(a,minint) and eqT(b,0.0))
85−assert(math.huge > 1e31.0)
85+assert(math.huge > 1e31)
86−assert(- math.huge < - 1e31.0)
86+assert(- math.huge < - 1e31)
87assert(minint < minint + 1)
87assert(minint < minint + 1)
88assert(maxint - 1 < maxint)
88assert(maxint - 1 < maxint)
89assert(0 - minint == minint)
89assert(0 - minint == minint)
@@ -313,13 +313,13 @@ return s
314assert(eqT(tonumber(incd(maxint)),maxint + 1.0))
314assert(eqT(tonumber(incd(maxint)),maxint + 1.0))
315assert(eqT(tonumber(incd(minint)),minint - 1.0))
315assert(eqT(tonumber(incd(minint)),minint - 1.0))
316−assert(eqT(tonumber("\49" .. string.rep("\48",30)),1e30.0))
316+assert(eqT(tonumber("\49" .. string.rep("\48",30)),1e30))
317−assert(eqT(tonumber("\45\49" .. string.rep("\48",30)),- 1e30.0))
317+assert(eqT(tonumber("\45\49" .. string.rep("\48",30)),- 1e30))
318assert(eqT(tonumber("\48\120\49" .. string.rep("\48",30)),0))
318assert(eqT(tonumber("\48\120\49" .. string.rep("\48",30)),0))
319assert(minint == load("\114\101\116\117\114\110\32" .. minint)())
319assert(minint == load("\114\101\116\117\114\110\32" .. minint)())
320assert(eqT(maxint,load("\114\101\116\117\114\110\32" .. maxint)()))
320assert(eqT(maxint,load("\114\101\116\117\114\110\32" .. maxint)()))
321−assert(eqT(1e22.0,10000000000000000000000))
321+assert(eqT(1e22,10000000000000000000000))
322−assert(eqT(- 1e22.0,- 10000000000000000000000))
322+assert(eqT(- 1e22,- 10000000000000000000000))
324assert(tonumber(3.4) == 3.4)
324assert(tonumber(3.4) == 3.4)
325assert(eqT(tonumber(3),3))
325assert(eqT(tonumber(3),3))
@@ -432,7 +432,7 @@ assert(100.0 == 100.0 and 0.01 == 0.01)
432assert(1111111111 - 1111111110 == 1.0)
432assert(1111111111 - 1111111110 == 1.0)
433assert(1.1 == "\49\46" + "\46\49")
433assert(1.1 == "\49\46" + "\46\49")
434assert(tonumber("\49\49\49\49\49\49\49\49\49\49") - tonumber("\49\49\49\49\49\49\49\49\49\48") == tonumber("\32\32\43\48\46\48\48\49\101\43\51\32\10\9"))
434assert(tonumber("\49\49\49\49\49\49\49\49\49\49") - tonumber("\49\49\49\49\49\49\49\49\49\48") == tonumber("\32\32\43\48\46\48\48\49\101\43\51\32\10\9"))
435−assert(1e-31.0 > 9e-32.0 and 9e29.0 < 1e30.0)
435+assert(1e-31 > 9e-32 and 9e29 < 1e30)
436assert(0.123456 > 0.123455)
436assert(0.123456 > 0.123455)
437assert(tonumber("\43\49\46\50\51\69\49\56") == 1.23 * 10.0 ^ 18)
437assert(tonumber("\43\49\46\50\51\69\49\56") == 1.23 * 10.0 ^ 18)
438assert(not (1 < 1) and (1 < 2) and not (2 < 1))
438assert(not (1 < 1) and (1 < 2) and not (2 < 1))
@@ -461,7 +461,7 @@ assert(eqT(10.0 % 2,0.0))
461assert(eqT(- 10.0 % 2,0.0))
461assert(eqT(- 10.0 % 2,0.0))
462assert(eqT(- 10.0 % - 2,0.0))
462assert(eqT(- 10.0 % - 2,0.0))
463assert(math.pi - math.pi % 1 == 3)
463assert(math.pi - math.pi % 1 == 3)
464−assert(math.pi - math.pi % 1e-3.0 == 3.141)
464+assert(math.pi - math.pi % 1e-3 == 3.141)
466local i,j = 0,20000
466local i,j = 0,20000
467while i < j do
467while i < j do
@@ -526,12 +526,12 @@ end
526anan(0.0 % 0)
526anan(0.0 % 0)
527anan(1.3 % 0)
527anan(1.3 % 0)
528anan(math.huge % 1)
528anan(math.huge % 1)
529−anan(math.huge % 1e30.0)
529+anan(math.huge % 1e30)
530−anan(- math.huge % 1e30.0)
530+anan(- math.huge % 1e30)
531−anan(- math.huge % - 1e30.0)
531+anan(- math.huge % - 1e30)
532assert(1 % math.huge == 1)
532assert(1 % math.huge == 1)
533−assert(1e30.0 % math.huge == 1e30.0)
533+assert(1e30 % math.huge == 1e30)
534−assert(1e30.0 % - math.huge == - math.huge)
534+assert(1e30 % - math.huge == - math.huge)
535assert(- 1 % math.huge == math.huge)
535assert(- 1 % math.huge == math.huge)
536assert(- 1 % - math.huge == - 1)
536assert(- 1 % - math.huge == - 1)
@@ -575,10 +575,10 @@ assert(eqT(math.floor(minint),minint))
575assert(eqT(math.floor(minint + 0.0),minint))
575assert(eqT(math.floor(minint + 0.0),minint))
576assert(eqT(math.ceil(minint),minint))
576assert(eqT(math.ceil(minint),minint))
577assert(eqT(math.ceil(minint + 0.0),minint))
577assert(eqT(math.ceil(minint + 0.0),minint))
578−assert(math.floor(1e50.0) == 1e50.0)
578+assert(math.floor(1e50) == 1e50)
579−assert(math.ceil(1e50.0) == 1e50.0)
579+assert(math.ceil(1e50) == 1e50)
580−assert(math.floor(- 1e50.0) == - 1e50.0)
580+assert(math.floor(- 1e50) == - 1e50)
581−assert(math.ceil(- 1e50.0) == - 1e50.0)
581+assert(math.ceil(- 1e50) == - 1e50)
582for _,p in pairs({31,32,63,64})
582for _,p in pairs({31,32,63,64})
584assert(math.floor(2 ^ p) == 2 ^ p)
584assert(math.floor(2 ^ p) == 2 ^ p)
@@ -632,13 +632,13 @@ checkerror("\118\97\108\117\101\32\101\120\112\101\99\116\101\100",math.max)
632checkerror("\118\97\108\117\101\32\101\120\112\101\99\116\101\100",math.min)
632checkerror("\118\97\108\117\101\32\101\120\112\101\99\116\101\100",math.min)
633assert(eqT(math.max(3),3))
633assert(eqT(math.max(3),3))
634assert(eqT(math.max(3,5,9,1),9))
634assert(eqT(math.max(3,5,9,1),9))
635−assert(math.max(maxint,1e61.0) == 1e61.0)
635+assert(math.max(maxint,1e61) == 1e61)
636assert(eqT(math.max(minint,minint + 1),minint + 1))
636assert(eqT(math.max(minint,minint + 1),minint + 1))
637assert(eqT(math.min(3),3))
637assert(eqT(math.min(3),3))
638assert(eqT(math.min(3,5,9,1),1))
638assert(eqT(math.min(3,5,9,1),1))
639assert(math.min(3.2,5.9,- 9.2,1.1) == - 9.2)
639assert(math.min(3.2,5.9,- 9.2,1.1) == - 9.2)
640assert(math.min(1.9,1.7,1.72) == 1.7)
640assert(math.min(1.9,1.7,1.72) == 1.7)
641−assert(math.min(- 1e61.0,minint) == - 1e61.0)
641+assert(math.min(- 1e61,minint) == - 1e61)
642assert(eqT(math.min(maxint,maxint - 1),maxint - 1))
642assert(eqT(math.min(maxint,maxint - 1),maxint - 1))
643assert(eqT(math.min(maxint - 2,maxint,maxint - 1),maxint - 2))
643assert(eqT(math.min(maxint - 2,maxint,maxint - 1),maxint - 2))
@@ -737,7 +737,7 @@ counts[bit + 1]=counts[bit + 1] + 1
739totalrounds=totalrounds + rounds
739totalrounds=totalrounds + rounds
740−if not (eq(up,1,1e-3.0) and eq(low,0,1e-3.0)) then
740+if not (eq(up,1,1e-3) and eq(low,0,1e-3)) then
741goto doagain
741goto doagain
743local expected = (totalrounds / randbits / 2)
743local expected = (totalrounds / randbits / 2)
@@ -780,7 +780,7 @@ if not testnear(counts[i],expected,0.1) then
780goto doagain
780goto doagain
783−print(string.format("\105\110\116\101\103\101\114\32\114\97\110\100\111\109\32\114\97\110\103\101\32\105\110\32\37\100\32\99\97\108\108\115\58\32\91\109\105\110\105\110\116\32\43\32\37\46\48\102\112\112\109\44\32\109\97\120\105\110\116\32\45\32\37\46\48\102\112\112\109\93",totalrounds,(minint - low) / minint * 1e6.0,(maxint - up) / maxint * 1e6.0))
783+print(string.format("\105\110\116\101\103\101\114\32\114\97\110\100\111\109\32\114\97\110\103\101\32\105\110\32\37\100\32\99\97\108\108\115\58\32\91\109\105\110\105\110\116\32\43\32\37\46\48\102\112\112\109\44\32\109\97\120\105\110\116\32\45\32\37\46\48\102\112\112\109\93",totalrounds,(minint - low) / minint * 1e6,(maxint - up) / maxint * 1e6))
786local count = {0,0,0,0,0,0}
786local count = {0,0,0,0,0,0}