Answers for "haskell float to int"

0

haskell float to int

-- Float to Int
toInt :: Float -> Int
toInt x = round x
Posted by: Guest on June-02-2021
0

int to float haskell

-- Int to Float
-- Useing (/) 
	(/) :: Fractional a => a -> a -> a

{- The following code works: -}

 	percent :: Int -> Int -> Float 
	percent x y =   100 * ( a / b )
      where a = fromIntegral x :: Float
            b = fromIntegral y :: Float
Posted by: Guest on June-02-2021

Browse Popular Code Answers by Language