File tree Expand file tree Collapse file tree 2 files changed +33
-46
lines changed
Expand file tree Collapse file tree 2 files changed +33
-46
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ // Returns e == 0 ? 1 : ceil(log_2(5^e)); requires 0 <= e <= 3528.
16+
17+ ///|
18+ fn pow5bits (e : Int ) -> Int {
19+ ((e * 1217359 ).reinterpret_as_uint () >> 19 ).reinterpret_as_int () + 1
20+ }
21+
22+ ///|
23+ fn copy_special_str (sign : Bool , exponent : Bool , mantissa : Bool ) -> String {
24+ if mantissa {
25+ return "NaN"
26+ }
27+ let s = if sign { "-" } else { "" }
28+ if exponent {
29+ return s + "Infinity"
30+ }
31+ return s + "0.0"
32+ }
33+
34+ // Returns floor(log_10(5^e)); requires 0 <= e <= 2620.
35+
36+ ///|
37+ fn log10Pow5 (e : Int ) -> Int {
38+ ((e * 732923 ).reinterpret_as_uint () >> 20 ).reinterpret_as_int ()
39+ }
40+
41+ // Returns floor(log_10(2^e)); requires 0 <= e <= 1650.
42+
43+ ///|
44+ fn log10Pow2 (e : Int ) -> Int {
45+ ((e * 78913 ).reinterpret_as_uint () >> 18 ).reinterpret_as_int ()
46+ }
47+
1548// MoonBit implementation of Ryu, https://github.com/ulfjack/ryu
1649// This is a fork of the ryu crate adjusted to comply to the ECMAScript number-to-string algorithm,
1750
You can’t perform that action at this time.
0 commit comments