File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,14 @@ exports.intDegree = function (x) {
88// https://en.m.wikipedia.org/wiki/Modulo_operation.
99exports . intDiv = function ( x ) {
1010 return function ( y ) {
11+ if ( y == 0 ) return 0 ;
1112 return y > 0 ? Math . floor ( x / y ) : - Math . floor ( x / - y ) ;
1213 } ;
1314} ;
1415
1516exports . intMod = function ( x ) {
1617 return function ( y ) {
18+ if ( y == 0 ) return 0 ;
1719 var yy = Math . abs ( y ) ;
1820 return ( ( x % yy ) + yy ) % yy ;
1921 } ;
Original file line number Diff line number Diff line change @@ -29,10 +29,6 @@ testOrd x y ord =
2929nan :: Number
3030nan = 0.0 /0.0
3131
32- -- Unfortunately, NaN inhabits our Int
33- intNan :: Int
34- intNan = mod 1 0
35-
3632plusInfinity :: Number
3733plusInfinity = 1.0 /0.0
3834
@@ -60,7 +56,8 @@ testOrderings = do
6056 assert " NaN > 1 should be false" $ (nan > 1.0 ) == false
6157 assert " NaN < 1 should be false" $ (nan < 1.0 ) == false
6258 assert " NaN == 1 should be false" $ nan /= 1.0
63- testOrd intNan 2147483647 GT
59+ testOrd (1 / 0 ) 0 EQ
60+ testOrd (mod 1 0 ) 0 EQ
6461 testOrd ' a' ' b' LT
6562 testOrd ' b' ' A' GT
6663 testOrd " 10" " 0" GT
You can’t perform that action at this time.
0 commit comments