|
158 | 158 | # @author https://github.com/SuperFola |
159 | 159 | (let NaN builtin__math:NaN) |
160 | 160 |
|
| 161 | +# @brief Count the number of '1' bits in the given value |
| 162 | +# @param value the Number, must be an integer |
| 163 | +# =begin |
| 164 | +# (math:countOnes 5) # 2 |
| 165 | +# =end |
| 166 | +# @author https://github.com/SuperFola |
| 167 | +# @require 4.6.0 Requires ArkScript 4.6.0 or later |
| 168 | +(let countOnes (fun (_x) (builtin__math:countOnes _x))) |
| 169 | + |
| 170 | +# @brief Count the number of '0' bits in the given value |
| 171 | +# @param value the Number, must be an integer |
| 172 | +# =begin |
| 173 | +# (math:countZeros 5) # 1 |
| 174 | +# =end |
| 175 | +# @author https://github.com/SuperFola |
| 176 | +# @require 4.6.0 Requires ArkScript 4.6.0 or later |
| 177 | +(let countZeros (fun (_x) (builtin__math:countZeros _x))) |
| 178 | + |
| 179 | +# @brief Invert a number on 64 bits |
| 180 | +# @param value Number, must be an integer |
| 181 | +# =begin |
| 182 | +# (math:bitNot 5) # -6 |
| 183 | +# =end |
| 184 | +# @author https://github.com/SuperFola |
| 185 | +# @require 4.6.0 Requires ArkScript 4.6.0 or later |
| 186 | +(let bitNot (fun (_x) (builtin__math:bitNot _x))) |
| 187 | + |
| 188 | +# @brief Bitwise and |
| 189 | +# @param lhs Number, must be an integer |
| 190 | +# @param rhs Number, must be an integer |
| 191 | +# =begin |
| 192 | +# (math:bitAnd 4 12) # 4 |
| 193 | +# (math:bitAnd 4 10) # 0 |
| 194 | +# =end |
| 195 | +# @author https://github.com/SuperFola |
| 196 | +# @require 4.6.0 Requires ArkScript 4.6.0 or later |
| 197 | +(let bitAnd (fun (_a _b) (builtin__math:bitAnd _a _b))) |
| 198 | + |
| 199 | +# @brief Bitwise or |
| 200 | +# @param lhs Number, must be an integer |
| 201 | +# @param rhs Number, must be an integer |
| 202 | +# =begin |
| 203 | +# (math:bitOr 4 10) # 14 |
| 204 | +# (math:bitOr 4 1) # 5 |
| 205 | +# =end |
| 206 | +# @author https://github.com/SuperFola |
| 207 | +# @require 4.6.0 Requires ArkScript 4.6.0 or later |
| 208 | +(let bitOr (fun (_a _b) (builtin__math:bitOr _a _b))) |
| 209 | + |
| 210 | +# @brief Bitwise exclusive or of lhs and rhs |
| 211 | +# @param lhs Number, must be an integer |
| 212 | +# @param rhs Number, must be an integer |
| 213 | +# =begin |
| 214 | +# (math:bitXor 4 12) # 8 |
| 215 | +# (math:bitXor 4 10) # 14 |
| 216 | +# =end |
| 217 | +# @author https://github.com/SuperFola |
| 218 | +# @require 4.6.0 Requires ArkScript 4.6.0 or later |
| 219 | +(let bitXor (fun (_a _b) (builtin__math:bitXor _a _b))) |
| 220 | + |
| 221 | +# @brief Left bit shift |
| 222 | +# @param lhs Number, must be an integer |
| 223 | +# @param rhs Number, must be an integer |
| 224 | +# =begin |
| 225 | +# (math:lshift 3 2) # 12 |
| 226 | +# =end |
| 227 | +# @author https://github.com/SuperFola |
| 228 | +# @require 4.6.0 Requires ArkScript 4.6.0 or later |
| 229 | +(let lshift (fun (_a _b) (builtin__math:lshift _a _b))) |
| 230 | + |
| 231 | +# @brief Right bit shift |
| 232 | +# @param lhs Number, must be an integer |
| 233 | +# @param rhs Number, must be an integer |
| 234 | +# =begin |
| 235 | +# (math:rshift 13 2) # 3 |
| 236 | +# (math:rshift -14 2) # -4 |
| 237 | +# =end |
| 238 | +# @author https://github.com/SuperFola |
| 239 | +# @require 4.6.0 Requires ArkScript 4.6.0 or later |
| 240 | +(let rshift (fun (_a _b) (builtin__math:rshift _a _b))) |
| 241 | + |
161 | 242 | # @brief Return the absolute value of a number |
162 | 243 | # @param _x the number to get the absolute value of |
163 | 244 | # @author https://github.com/rstefanic |
|
0 commit comments