aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/math/number/i64.lux
blob: 03c3d8d1dcb16dae09195785d125b2883248ad9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
(.using
 [library
  [lux {"-" or and not}
   ["$" documentation (.only documentation:)]
   [data
    ["[0]" text (.only \n)
     ["%" format (.only format)]]]
   [macro
    ["[0]" template]]]]
 [\\library
  ["[0]" /]])

(template [<name> <doc>]
  [(documentation: <name>
     <doc>)]

  [/.or "Bitwise or."]
  [/.xor "Bitwise xor."]
  [/.and "Bitwise and."]
  
  [/.left_shifted "Bitwise left-shift."]
  [/.right_shifted "Unsigned/logic bitwise right-shift."]
  )

(documentation: /.Mask
  "A pattern of bits that can be imposed on I64 values.")

(documentation: /.bit
  "A mask with only a specific bit set."
  [(bit position)])

(documentation: /.sign
  "A mask for the sign bit of ints.")

(documentation: /.not
  "Bitwise negation.")

(documentation: /.mask
  "Mask a block of bits of the specified size."
  [(mask amount_of_bits)])

(documentation: /.ones
  "Count the number of 1s in a bit-map."
  [(ones it)])

(template [<name> <doc>]
  [(documentation: <name>
     <doc>)]

  [/.zero "Clear bit at the given index."]
  [/.one "Set bit at given index."]
  [/.flipped "Flip bit at given index."]
  )

(documentation: /.one?
  ""
  [(one? index input)])

(documentation: /.zero?
  ""
  [(zero? index input)])

(documentation: /.region
  "A mask for a block of bits of the given size, starting at the given offset."
  [(region offset size)])

(documentation: (/.Sub width)
  "A sub-space of I64 with a reduce amount of bits.")

(documentation: /.sub
  "Given a width in the interval (0,64), yields an implementation for integers of that width."
  [(sub width)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..or
             ..xor
             ..and
             ..left_shifted
             ..right_shifted
             ..Mask
             ..bit
             ..sign
             ..not
             ..mask
             ..ones
             ..zero
             ..one
             ..flipped
             ..one?
             ..zero?
             ..region
             ..Sub
             ..sub
             ($.default /.bits_per_byte)
             ($.default /.bytes_per_i64)
             ($.default /.width)
             ($.default /.false)
             ($.default /.true)
             ($.default /.equivalence)
             ($.default /.hash)
             ($.default /.disjunction)
             ($.default /.conjunction)
             ($.default /.reversed)
             ($.default /.left_rotated)
             ($.default /.right_rotated)]
            []))