Copyright 2020 Junekey Jeon Copyright 2020 Alexander Bolz
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
char* output_end = Dtoa(buffer, value);
Converts the given double-precision number into decimal form and stores the result in the given buffer.
The buffer must be large enough, i.e. >= DtoaMinBufferLength. The output format is similar to printf("%g"). The output is _not null-terminted.
The output is optimal, i.e. the output string
- rounds back to the input number when read in (using round-to-nearest-even)
- is as short as possible,
- is as close to the input number as possible.
Note: This function may temporarily write up to DtoaMinBufferLength characters into the buffer.
This file contains an implementation of Junekey Jeon's Dragonbox algorithm.
It is a simplified version of the reference implementation found here: https://github.com/jk-jeon/dragonbox
The reference implementation also works with single-precision floating-point numbers and has options to configure the rounding mode.
namespace Returns floor(x / 2^n).
Technically, right-shift of negative integers is implementation defined... Should easily be optimized into SAR (or equivalent) instruction.
Returns whether value is divisible by 2^e2Returns whether value is divisible by 5^e5Returns (x * y) / 2^128Procs
proc toDecimal64(ieeeSignificand: uint64; ieeeExponent: uint64): FloatingDecimal64 {. inline, ...raises: [], tags: [], forbids: [].}
- Source Edit
proc toDecimal64AsymmetricInterval(e2: int32): FloatingDecimal64 {.inline, ...raises: [], tags: [], forbids: [].}
- NB: accept_lower_endpoint = true accept_upper_endpoint = true Source Edit