File tree Expand file tree Collapse file tree 2 files changed +65
-1
lines changed Expand file tree Collapse file tree 2 files changed +65
-1
lines changed Original file line number Diff line number Diff line change 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+ -- | ```
248module Data.Int64
349 ( module R
450 , fromLowHighBits
Original file line number Diff line number Diff line change @@ -2,14 +2,32 @@ module Test.Main where
22
33import Prelude
44
5+ import Data.Int64 as Int64
56import Data.Long.FFISpec (ffiSpec )
67import Data.Long.InternalSpec (internalSpec )
78import Effect (Effect )
89import Effect.Aff (launchAff_ )
10+ import Test.Spec (describe , it )
11+ import Test.Spec.Assertions (shouldEqual )
912import Test.Spec.Reporter (consoleReporter )
1013import Test.Spec.Runner (runSpec )
1114
1215main :: Effect Unit
1316main = 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"
You can’t perform that action at this time.
0 commit comments