by Ricardo “Rudxain” Fernández Serrata
Version 2 (September 26, 2023)
Download (59 downloads)
Keep the bits intact, change the numerical value, as if you were using actual integers.
Converts the truncated input number into the value it would have as an unsigned or signed b-bit integer.
If `b` is negative, converts to signed, otherwise unsigned.
If `b >= -32 && b < 32`, it makes values safe to use with bitwise operators/functions like `hexEncode` and `ctz`, because AM clamps instead of wrapping-around (saturating arithmetic, instead of modular).
This algorithm is based on Ecmascript's integer-conversion algorithms:
https://tc39.es/ecma262/#sec-toint32
https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-bigint.asintn
Rudxain profile: llamalab.com/automate/community/flows/42921
LICENSE: https://unlicense.org
5 stars | 0 | |
4 stars | 0 | |
3 stars | 1 | |
2 stars | 0 | |
1 star | 0 | |
Reports | 0 |
Rate and review within the app in the Community section.