开发者

Haskell Int -> Word64 conversion

开发者 https://www.devze.com 2023-02-02 20:55 出处:网络
This should be pretty simple. I have an Int and I want to convert it to a Word64. It can never 开发者_运维知识库be less than 0. I don\'t mind if it has error checking or not. It seems I can do the opp

This should be pretty simple. I have an Int and I want to convert it to a Word64. It can never 开发者_运维知识库be less than 0. I don't mind if it has error checking or not. It seems I can do the opposite conversion using fromIntegral, but I can't find the inverse function.

Thanks.


well,

fromIntegral :: (Integral a, Num b) => a -> b

should be perfectly capable of converting from Int to Word64 since Int is an instance of Integral and Word64 is an instance of Num

0

精彩评论

暂无评论...
验证码 换一张
取 消