[project @ 1997-01-17 00:32:23 by simonpj]
[ghc-hetmet.git] / ghc / lib / ghc / PrelNum.lhs
index 7db21c4..bf16dc0 100644 (file)
@@ -18,7 +18,7 @@ It's rather big!
 
 module PrelNum where
 
-import {#- SOURCE #-}  IOBase  ( error )
+import {-# SOURCE #-}  IOBase  ( error )
 import PrelList
 import PrelBase
 import GHC
@@ -350,6 +350,19 @@ integer_0 = 0; integer_1 = 1; integer_2 = 2; integer_m1 = -1
 %*********************************************************
 
 \begin{code}
+instance Eq Float where
+    (F# x) == (F# y) = x `eqFloat#` y
+
+instance Ord Float where
+    (F# x) `compare` (F# y) | x `ltFloat#` y = LT
+                           | x `eqFloat#` y = EQ
+                           | otherwise      = GT
+
+    (F# x) <  (F# y) = x `ltFloat#`  y
+    (F# x) <= (F# y) = x `leFloat#`  y
+    (F# x) >= (F# y) = x `geFloat#`  y
+    (F# x) >  (F# y) = x `geFloat#`  y
+
 instance  Num Float  where
     (+)                x y     =  plusFloat x y
     (-)                x y     =  minusFloat x y
@@ -472,6 +485,19 @@ instance  Show Float  where
 %*********************************************************
 
 \begin{code}
+instance Eq Double where
+    (D# x) == (D# y) = x ==## y
+
+instance Ord Double where
+    (D# x) `compare` (D# y) | x <## y   = LT
+                           | x ==## y  = EQ
+                           | otherwise = GT
+
+    (D# x) <  (D# y) = x <##  y
+    (D# x) <= (D# y) = x <=## y
+    (D# x) >= (D# y) = x >=## y
+    (D# x) >  (D# y) = x >##  y
+
 instance  Num Double  where
     (+)                x y     =  plusDouble x y
     (-)                x y     =  minusDouble x y