Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdbrock committed May 9, 2022
1 parent 329b9fc commit 6cba8be
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/Data/Int64.purs
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
-- | Signed 2’s-complement 64-bit integers.
-- | Signed two’s-complement 64-bit integers and operations.
-- |
-- | All of the usual arithmetic operations are supplied by typeclass
-- | instances from typeclasses in the __Prelude__.
-- |
-- | The `Show` instance will suffix a lowercase ‘l’ for “long”.
-- |
-- | #### Usage
-- |
-- | ```purescript
-- | import Prelude
-- | import Data.Int64 as Int64
-- |
-- | let
-- | hundred = Int64.fromInt 100
-- | billion = Int64.fromInt 1000000000
-- | ```
-- | ---
-- | ```purescript
-- | > hundred * billion
-- | 100000000000l
-- | ```
-- | ---
-- | ```purescript
-- | > billion / hundred
-- | 10000000l
-- | ```
-- | ---
-- | ```purescript
-- | > hundred + one
-- | 101l
-- | ```
-- | ---
-- | ```purescript
-- | > hundred * zero
-- | 0l
-- | ```
-- | ---
-- | ```purescript
-- | > Int64.lowBits (hundred * billion)
-- | 1215752192
-- | ```
-- | ---
-- | ```purescript
-- | > Int64.highBits (hundred * billion)
-- | 23
-- | ```
module Data.Int64
( module R
, fromLowHighBits
Expand Down
18 changes: 18 additions & 0 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,32 @@ module Test.Main where

import Prelude

import Data.Int64 as Int64
import Data.Long.FFISpec (ffiSpec)
import Data.Long.InternalSpec (internalSpec)
import Effect (Effect)
import Effect.Aff (launchAff_)
import Test.Spec (describe, it)
import Test.Spec.Assertions (shouldEqual)
import Test.Spec.Reporter (consoleReporter)
import Test.Spec.Runner (runSpec)

main :: Effect Unit
main = launchAff_ $ runSpec [ consoleReporter ] do
ffiSpec
internalSpec
describe "Examples" do
it "Example1" do
let
hundred = Int64.fromInt 100
billion = Int64.fromInt 1000000000
hundredbillion = hundred * billion
shouldEqual
(show hundredbillion)
("100000000000l")
shouldEqual (Int64.fromInt 0) zero
shouldEqual
(billion / hundred)
(Int64.fromInt 10000000)
shouldEqual (show $ Int64.lowBits hundredbillion) "1215752192"
shouldEqual (show $ Int64.highBits hundredbillion) "23"

0 comments on commit 6cba8be

Please sign in to comment.