Module

Data.UInt64

Package
purescript-int64
Repository
purescript-contrib/purescript-int64

Unsigned 64-bit integers and operations.

All of the usual arithmetic operations are supplied by typeclass instances.

Usage

import Prelude
import Data.UInt64 as UInt64

let
  hundred = UInt64.unsafeFromInt 100
  billion = UInt64.unsafeFromInt 1000000000

> hundred * billion
100000000000ul

> billion / hundred
10000000ul

> hundred + one
101ul

> hundred * zero
0ul

#UInt64 Source

newtype UInt64

Unsigned 64-bit integer.

Instances

#fromInt Source

fromInt :: Int -> Maybe UInt64

Creates a UInt64 from an Int value.

#unsafeFromInt Source

unsafeFromInt :: Int -> UInt64

Creates a UInt64 from an Int value.

If the Int is negative, the result is undefined.

#fromLowHighBits Source

fromLowHighBits :: Int -> Int -> UInt64

Creates a UInt64 from low and high bits represented as Int.

#fromNumber Source

fromNumber :: Number -> Maybe UInt64

Creates a UInt64 from a Number value. The number must already be an integer and fall within the valid range of values for the UInt64 type otherwise Nothing is returned.

#fromString Source

fromString :: String -> Maybe UInt64

Reads a UInt64 from a String value. The number must parse as an integer and fall within the valid range of values for the UInt64 type, otherwise Nothing is returned.

#fromStringAs Source

fromStringAs :: Radix -> String -> Maybe UInt64

Like fromString, but the integer can be specified in a different base.

#lowBits Source

lowBits :: UInt64 -> Int

Get the low (least significant) 32 bits of a UInt64 as an Int.

#highBits Source

highBits :: UInt64 -> Int

Get the high (most significant) 32 bits of a UInt64 as an Int.

#toInt Source

toInt :: UInt64 -> Maybe Int

Creates an Int if the UInt64 value is positive.

#toNumber Source

toNumber :: UInt64 -> Number

Creates a Number value from a UInt64. Values greater than Number.MAX_SAFE_INTEGER will lose precision.

#toString Source

toString :: UInt64 -> String

Like show, but omits the ul suffix.

#toStringAs Source

toStringAs :: Radix -> UInt64 -> String

Like toString, but the integer can be specified in a different base.

#parity Source

parity :: UInt64 -> Parity

Returns whether a UInt64 is Even or Odd.

#even Source

even :: UInt64 -> Boolean

Returns true if an even number.

#odd Source

odd :: UInt64 -> Boolean

Returns true if an odd number.

#quot Source

quot :: UInt64 -> UInt64 -> UInt64

quot is identical to div.

#rem Source

rem :: UInt64 -> UInt64 -> UInt64

rem is identical to mod.

#and Source

and :: UInt64 -> UInt64 -> UInt64

Bitwise AND.

#(.&.) Source

Operator alias for Data.UInt64.and (left-associative / precedence 10)

#or Source

or :: UInt64 -> UInt64 -> UInt64

Bitwise OR.

#(.|.) Source

Operator alias for Data.UInt64.or (left-associative / precedence 10)

#xor Source

xor :: UInt64 -> UInt64 -> UInt64

Bitwise XOR.

#(.^.) Source

Operator alias for Data.UInt64.xor (left-associative / precedence 10)

#shl Source

shl :: UInt64 -> UInt64 -> UInt64

Bitwise shift left.

#shr Source

shr :: UInt64 -> UInt64 -> UInt64

Bitwise shift right.

#zshr Source

zshr :: UInt64 -> UInt64 -> UInt64

Bitwise zero-fill shift right.

#complement Source

complement :: UInt64 -> UInt64

Bitwise NOT.