Skip to content

Commit 6cba8be

Browse files
committed
Docs
1 parent 329b9fc commit 6cba8be

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

src/Data/Int64.purs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,50 @@
1-
-- | Signed 2’s-complement 64-bit integers.
1+
-- | Signed two’s-complement 64-bit integers and operations.
2+
-- |
3+
-- | All of the usual arithmetic operations are supplied by typeclass
4+
-- | instances from typeclasses in the __Prelude__.
5+
-- |
6+
-- | The `Show` instance will suffix a lowercase ‘l’ for “long”.
7+
-- |
8+
-- | #### Usage
9+
-- |
10+
-- | ```purescript
11+
-- | import Prelude
12+
-- | import Data.Int64 as Int64
13+
-- |
14+
-- | let
15+
-- | hundred = Int64.fromInt 100
16+
-- | billion = Int64.fromInt 1000000000
17+
-- | ```
18+
-- | ---
19+
-- | ```purescript
20+
-- | > hundred * billion
21+
-- | 100000000000l
22+
-- | ```
23+
-- | ---
24+
-- | ```purescript
25+
-- | > billion / hundred
26+
-- | 10000000l
27+
-- | ```
28+
-- | ---
29+
-- | ```purescript
30+
-- | > hundred + one
31+
-- | 101l
32+
-- | ```
33+
-- | ---
34+
-- | ```purescript
35+
-- | > hundred * zero
36+
-- | 0l
37+
-- | ```
38+
-- | ---
39+
-- | ```purescript
40+
-- | > Int64.lowBits (hundred * billion)
41+
-- | 1215752192
42+
-- | ```
43+
-- | ---
44+
-- | ```purescript
45+
-- | > Int64.highBits (hundred * billion)
46+
-- | 23
47+
-- | ```
248
module Data.Int64
349
( module R
450
, fromLowHighBits

test/Main.purs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,32 @@ module Test.Main where
22

33
import Prelude
44

5+
import Data.Int64 as Int64
56
import Data.Long.FFISpec (ffiSpec)
67
import Data.Long.InternalSpec (internalSpec)
78
import Effect (Effect)
89
import Effect.Aff (launchAff_)
10+
import Test.Spec (describe, it)
11+
import Test.Spec.Assertions (shouldEqual)
912
import Test.Spec.Reporter (consoleReporter)
1013
import Test.Spec.Runner (runSpec)
1114

1215
main :: Effect Unit
1316
main = launchAff_ $ runSpec [ consoleReporter ] do
1417
ffiSpec
1518
internalSpec
19+
describe "Examples" do
20+
it "Example1" do
21+
let
22+
hundred = Int64.fromInt 100
23+
billion = Int64.fromInt 1000000000
24+
hundredbillion = hundred * billion
25+
shouldEqual
26+
(show hundredbillion)
27+
("100000000000l")
28+
shouldEqual (Int64.fromInt 0) zero
29+
shouldEqual
30+
(billion / hundred)
31+
(Int64.fromInt 10000000)
32+
shouldEqual (show $ Int64.lowBits hundredbillion) "1215752192"
33+
shouldEqual (show $ Int64.highBits hundredbillion) "23"

0 commit comments

Comments
 (0)