Possible Duplicate:
Haskell Error: Couldn't match expected typeInteger' against inferred type
Int'
How can I convert Int
to Integer
in Haskell?
Convert Int to Integer Using the Integer. valueOf() Method in Java. This is another that we can use to convert an int to an Integer in Java. Here, we used valueOf() method of the Integer class.
We can convert int value to Double object by instantiating Double class or calling Double. valueOf() method.
Use Integer constructor to convert int primitive type to Integer object.
There are special cases for converting from Integer s: fromInteger :: Num a => Integer -> a. as well as for converting to Integer s: toInteger:: Integral a => a -> Integer.
There is a toInteger
function you can use.
fromIntegral is a good generic way to convert any Integral value into any other Integeral. But as sth said, toInteger works for the case of converting specifically to an Integer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With