Changeset 8055
- Timestamp:
- 12/03/05 07:32:09 (3 years ago)
- svk:copy_cache_prev:
- 10519
- Files:
-
- 2 modified
-
src/Pugs/Prim/Numeric.hs (modified) (2 diffs)
-
t/operators/arith.t (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Prim/Numeric.hs
r8054 r8055 61 61 if isDigit . head $ show (num1 :: VNum) 62 62 then op2Rat ((^^) :: VRat -> VInt -> VRat) x y 63 else op2Num numExp x y 64 _ -> op2Num numExp x y 65 where 66 numExp :: VNum -> VNum -> VNum 67 -- Perl 6 differs from Haskell in the floating point spec wrt Infinity and NaN 68 numExp x y 69 | x == 1/0 && y == 0 = 0/0 70 | x == 0 && y < 0 = 0/0 71 | y == 1/0 && (x == 1 || x <= -1) = 0/0 72 | y == -1/0 && (x == 1 || (x >= -1 && x <= 0)) = 0/0 73 | otherwise = x ** y 63 else op2Num ((**) :: VNum -> VNum -> VNum) x y 64 _ -> op2Num ((**) :: VNum -> VNum -> VNum) x y 74 65 75 66 op2Divide :: Val -> Val -> Eval Val … … 86 77 = op2Num (/) x y 87 78 where 88 err = fail "Illegal division by zero" -- XXX why not NaN?79 err = fail "Illegal division by zero" 89 80 90 81 op2Modulus :: Val -> Val -> Eval Val -
t/operators/arith.t
r8054 r8055 4 4 use Test; 5 5 6 plan 1 96;6 plan 185; 7 7 8 8 my $five = abs(-5); … … 311 311 is Inf/Inf, NaN; 312 312 is Inf*Inf/Inf, NaN; 313 is Inf**0, 1; 313 314 is 0**Inf, 0; 314 315 … … 323 324 is 0.9**Inf, 0, "0.9**Inf converges towards 0"; 324 325 is 1.1**Inf, Inf, "1.1**Inf diverges towards Inf"; 325 # this next one is arguable 326 is 1**Inf, NaN, "1**Inf depends on the functions in the limit (unless 1 is considered an int)"; 327 # but this next one isn't 328 is 1.0**Inf, NaN, "1.0**Inf depends on the functions in the limit"; 329 is (-1)**Inf, NaN, "(-1)**Inf is indeterminate for the same reason"; 330 is (-1.1)**Inf, NaN, "(-2)**Inf is indeterminate between -Inf and Inf"; 331 is (-0.9)**Inf, 0, "(-0.9)**Inf oscillates but always converges to 0"; 332 333 is 0.9**(-Inf), Inf, "0.9**-Inf diverges towards Inf"; 334 is 1.1**(-Inf), 0, "1.1**-Inf converges to 0"; 335 is 1**(-Inf), NaN, "1**Inf depends on the functions in the limit"; 336 is 1.0**(-Inf), NaN, "1.0**Inf depends on the functions in the limit"; 337 is (-1)**(-Inf), NaN, "(-1)**-Inf is indeterminate"; 338 is (-1.1)**(-Inf), 0, "(-1.1)**-Inf converges to 0"; 339 is (-0.9)**(-Inf), NaN, "(0.9)**-Inf oscillates and diverges"; 340 341 is Inf**0, NaN; 326 is 1**Inf, 1 , :todo("1**Inf == 1"); 342 327 343 328 #fail("1**Inf is platform-specific -- it's 1 on OSX and NaN elsewhere", :todo);
