Module

Data.Int64

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

Signed two’s-complement 64-bit integers and operations.

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

Usage

import Prelude
import Data.Int64 as Int64

let
  hundred = Int64.fromInt 100
  billion = Int64.fromInt 1000000000

> hundred * billion
100000000000l

> billion / hundred
10000000l

> hundred + one
101l

> hundred * zero
0l

> Int64.lowBits (hundred * billion)
1215752192

> Int64.highBits (hundred * billion)
23

#Int64 Source

newtype Int64

Signed two’s-complement 64-bit integer.

Instances

#fromInt Source

fromInt :: Int -> Int64

Creates an Int64 from an Int value.

#fromLowHighBits Source

fromLowHighBits :: Int -> Int -> Int64

Creates an Int64 from low and high bits represented as Int.

#fromNumber Source

fromNumber :: Number -> Maybe Int64

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

#fromString Source

fromString :: String -> Maybe Int64

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

#fromStringAs Source

fromStringAs :: Radix -> String -> Maybe Int64

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

#lowBits Source

lowBits :: Int64 -> Int

Get the low (least significant) bits of an Int64 as an Int.

#highBits Source

highBits :: Int64 -> Int

Get the high (most significant) bits of an Int64 as an Int.

#toInt Source

toInt :: Int64 -> Maybe Int

Creates an Int if the Int64 value is within the range of Int64.

#toNumber Source

toNumber :: Int64 -> Number

Creates a Number value from a Int64. Values not within Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER will lose precision.

#toString Source

toString :: Int64 -> String

Like show, but omits the l suffix.

#toStringAs Source

toStringAs :: Radix -> Int64 -> String

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

#parity Source

parity :: Int64 -> Parity

Returns whether a Int64 is Even or Odd.

#even Source

even :: Int64 -> Boolean

Returns true if an even number.

#odd Source

odd :: Int64 -> Boolean

Returns true if an odd number.

#quot Source

quot :: Int64 -> Int64 -> Int64

The quot function provides truncating long division (see the documentation for the EuclideanRing class). It is identical to div in the EuclideanRing Int instance if the dividend is positive, but will be slightly different if the dividend is negative.

#rem Source

rem :: Int64 -> Int64 -> Int64

The rem function provides the remainder after truncating long division (see the documentation for the EuclideanRing class). It is identical to mod in the EuclideanRing Int instance if the dividend is positive, but will be slightly different if the dividend is negative.

#toUnsigned Source

toUnsigned :: Int64 -> UInt64

Converts to a UInt64 by casting the bits as a 64-bit unsigned integer.

#toSigned Source

toSigned :: UInt64 -> Int64

Converts to an Int64 by casting the bits as a 2’s-complement 64-bit signed integer.

#and Source

and :: Int64 -> Int64 -> Int64

Bitwise AND.

#(.&.) Source

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

#or Source

or :: Int64 -> Int64 -> Int64

Bitwise OR.

#(.|.) Source

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

#xor Source

xor :: Int64 -> Int64 -> Int64

Bitwise XOR.

#(.^.) Source

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

#shl Source

shl :: Int64 -> Int64 -> Int64

Bitwise shift left.

#shr Source

shr :: Int64 -> Int64 -> Int64

Bitwise shift right.

#zshr Source

zshr :: Int64 -> Int64 -> Int64

Bitwise zero-fill shift right.

#complement Source

complement :: Int64 -> Int64

Bitwise NOT.