koffi 2.3.6-beta.6 → 2.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +2 -2
- package/src/cnoke/cnoke.js +3 -7
- package/src/cnoke/src/builder.js +9 -6
- package/src/cnoke/src/index.js +2 -2
- package/src/koffi/build/2.3.7/koffi_darwin_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_darwin_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_openbsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.7/koffi_win32_x64/koffi.node +0 -0
- package/src/koffi/src/ffi.cc +2 -2
- package/src/koffi/src/index.d.ts +2 -2
- package/src/koffi/src/index.js +1 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_darwin_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_darwin_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_freebsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_arm32hf/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_riscv64hf64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_linux_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_openbsd_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_openbsd_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_arm64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_arm64/koffi.pdb +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_ia32/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_ia32/koffi.pdb +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_x64/koffi.node +0 -0
- package/src/koffi/build/2.3.6-beta.6/koffi_win32_x64/koffi.pdb +0 -0
- package/vendor/brotli/BUILD +0 -144
- package/vendor/brotli/CMakeLists.txt +0 -421
- package/vendor/brotli/CONTRIBUTING.md +0 -27
- package/vendor/brotli/LICENSE +0 -19
- package/vendor/brotli/MANIFEST.in +0 -17
- package/vendor/brotli/Makefile +0 -55
- package/vendor/brotli/Makefile.am +0 -38
- package/vendor/brotli/README +0 -15
- package/vendor/brotli/README.md +0 -104
- package/vendor/brotli/WORKSPACE +0 -21
- package/vendor/brotli/bootstrap +0 -35
- package/vendor/brotli/c/common/constants.c +0 -15
- package/vendor/brotli/c/common/constants.h +0 -200
- package/vendor/brotli/c/common/context.c +0 -156
- package/vendor/brotli/c/common/context.h +0 -113
- package/vendor/brotli/c/common/dictionary.c +0 -5914
- package/vendor/brotli/c/common/dictionary.h +0 -64
- package/vendor/brotli/c/common/platform.c +0 -22
- package/vendor/brotli/c/common/platform.h +0 -596
- package/vendor/brotli/c/common/transform.c +0 -291
- package/vendor/brotli/c/common/transform.h +0 -85
- package/vendor/brotli/c/common/version.h +0 -26
- package/vendor/brotli/c/dec/bit_reader.c +0 -76
- package/vendor/brotli/c/dec/bit_reader.h +0 -351
- package/vendor/brotli/c/dec/decode.c +0 -2608
- package/vendor/brotli/c/dec/huffman.c +0 -339
- package/vendor/brotli/c/dec/huffman.h +0 -121
- package/vendor/brotli/c/dec/prefix.h +0 -732
- package/vendor/brotli/c/dec/state.c +0 -159
- package/vendor/brotli/c/dec/state.h +0 -365
- package/vendor/brotli/c/enc/backward_references.c +0 -145
- package/vendor/brotli/c/enc/backward_references.h +0 -39
- package/vendor/brotli/c/enc/backward_references_hq.c +0 -843
- package/vendor/brotli/c/enc/backward_references_hq.h +0 -95
- package/vendor/brotli/c/enc/backward_references_inc.h +0 -163
- package/vendor/brotli/c/enc/bit_cost.c +0 -35
- package/vendor/brotli/c/enc/bit_cost.h +0 -63
- package/vendor/brotli/c/enc/bit_cost_inc.h +0 -127
- package/vendor/brotli/c/enc/block_encoder_inc.h +0 -34
- package/vendor/brotli/c/enc/block_splitter.c +0 -194
- package/vendor/brotli/c/enc/block_splitter.h +0 -51
- package/vendor/brotli/c/enc/block_splitter_inc.h +0 -440
- package/vendor/brotli/c/enc/brotli_bit_stream.c +0 -1314
- package/vendor/brotli/c/enc/brotli_bit_stream.h +0 -84
- package/vendor/brotli/c/enc/cluster.c +0 -56
- package/vendor/brotli/c/enc/cluster.h +0 -48
- package/vendor/brotli/c/enc/cluster_inc.h +0 -320
- package/vendor/brotli/c/enc/command.c +0 -28
- package/vendor/brotli/c/enc/command.h +0 -190
- package/vendor/brotli/c/enc/compress_fragment.c +0 -790
- package/vendor/brotli/c/enc/compress_fragment.h +0 -61
- package/vendor/brotli/c/enc/compress_fragment_two_pass.c +0 -645
- package/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -54
- package/vendor/brotli/c/enc/dictionary_hash.c +0 -1846
- package/vendor/brotli/c/enc/dictionary_hash.h +0 -25
- package/vendor/brotli/c/enc/encode.c +0 -1927
- package/vendor/brotli/c/enc/encoder_dict.c +0 -33
- package/vendor/brotli/c/enc/encoder_dict.h +0 -43
- package/vendor/brotli/c/enc/entropy_encode.c +0 -503
- package/vendor/brotli/c/enc/entropy_encode.h +0 -122
- package/vendor/brotli/c/enc/entropy_encode_static.h +0 -539
- package/vendor/brotli/c/enc/fast_log.c +0 -105
- package/vendor/brotli/c/enc/fast_log.h +0 -66
- package/vendor/brotli/c/enc/find_match_length.h +0 -79
- package/vendor/brotli/c/enc/hash.h +0 -488
- package/vendor/brotli/c/enc/hash_composite_inc.h +0 -125
- package/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +0 -293
- package/vendor/brotli/c/enc/hash_longest_match64_inc.h +0 -267
- package/vendor/brotli/c/enc/hash_longest_match_inc.h +0 -262
- package/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +0 -266
- package/vendor/brotli/c/enc/hash_rolling_inc.h +0 -212
- package/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +0 -329
- package/vendor/brotli/c/enc/histogram.c +0 -100
- package/vendor/brotli/c/enc/histogram.h +0 -63
- package/vendor/brotli/c/enc/histogram_inc.h +0 -51
- package/vendor/brotli/c/enc/literal_cost.c +0 -175
- package/vendor/brotli/c/enc/literal_cost.h +0 -30
- package/vendor/brotli/c/enc/memory.c +0 -170
- package/vendor/brotli/c/enc/memory.h +0 -114
- package/vendor/brotli/c/enc/metablock.c +0 -663
- package/vendor/brotli/c/enc/metablock.h +0 -105
- package/vendor/brotli/c/enc/metablock_inc.h +0 -183
- package/vendor/brotli/c/enc/params.h +0 -46
- package/vendor/brotli/c/enc/prefix.h +0 -53
- package/vendor/brotli/c/enc/quality.h +0 -165
- package/vendor/brotli/c/enc/ringbuffer.h +0 -167
- package/vendor/brotli/c/enc/static_dict.c +0 -486
- package/vendor/brotli/c/enc/static_dict.h +0 -40
- package/vendor/brotli/c/enc/static_dict_lut.h +0 -5864
- package/vendor/brotli/c/enc/utf8_util.c +0 -85
- package/vendor/brotli/c/enc/utf8_util.h +0 -32
- package/vendor/brotli/c/enc/write_bits.h +0 -87
- package/vendor/brotli/c/include/brotli/decode.h +0 -344
- package/vendor/brotli/c/include/brotli/encode.h +0 -448
- package/vendor/brotli/c/include/brotli/port.h +0 -288
- package/vendor/brotli/c/include/brotli/types.h +0 -83
- package/vendor/brotli/c/tools/brotli.c +0 -1116
- package/vendor/brotli/c/tools/brotli.md +0 -107
- package/vendor/brotli/compiler_config_setting.bzl +0 -28
- package/vendor/brotli/configure +0 -8
- package/vendor/brotli/configure-cmake +0 -318
- package/vendor/brotli/configure.ac +0 -14
- package/vendor/brotli/docs/brotli.1 +0 -132
- package/vendor/brotli/docs/constants.h.3 +0 -47
- package/vendor/brotli/docs/decode.h.3 +0 -415
- package/vendor/brotli/docs/encode.h.3 +0 -586
- package/vendor/brotli/docs/types.h.3 +0 -117
- package/vendor/brotli/premake5.lua +0 -78
- package/vendor/brotli/python/Makefile +0 -57
- package/vendor/brotli/python/README.md +0 -54
- package/vendor/brotli/python/_brotli.cc +0 -753
- package/vendor/brotli/python/bro.py +0 -160
- package/vendor/brotli/python/brotli.py +0 -56
- package/vendor/brotli/python/tests/__init__.py +0 -0
- package/vendor/brotli/python/tests/_test_utils.py +0 -112
- package/vendor/brotli/python/tests/bro_test.py +0 -102
- package/vendor/brotli/python/tests/compress_test.py +0 -41
- package/vendor/brotli/python/tests/compressor_test.py +0 -94
- package/vendor/brotli/python/tests/decompress_test.py +0 -42
- package/vendor/brotli/python/tests/decompressor_test.py +0 -59
- package/vendor/brotli/scripts/libbrotlicommon.pc.in +0 -11
- package/vendor/brotli/scripts/libbrotlidec.pc.in +0 -12
- package/vendor/brotli/scripts/libbrotlienc.pc.in +0 -12
- package/vendor/brotli/scripts/sources.lst +0 -104
- package/vendor/brotli/setup.cfg +0 -5
- package/vendor/brotli/setup.py +0 -293
- package/vendor/brotli/tests/Makefile +0 -17
- package/vendor/brotli/tests/compatibility_test.sh +0 -25
- package/vendor/brotli/tests/roundtrip_test.sh +0 -36
- package/vendor/brotli/tests/run-compatibility-test.cmake +0 -31
- package/vendor/brotli/tests/run-roundtrip-test.cmake +0 -36
- package/vendor/brotli/tests/testdata/empty +0 -0
- package/vendor/brotli/tests/testdata/empty.compressed +0 -1
- package/vendor/brotli/tests/testdata/ukkonooa +0 -1
- package/vendor/brotli/tests/testdata/ukkonooa.compressed +0 -0
- package/vendor/dragonbox/CMakeLists.txt +0 -123
- package/vendor/dragonbox/LICENSE-Apache2-LLVM +0 -218
- package/vendor/dragonbox/LICENSE-Boost +0 -23
- package/vendor/dragonbox/README.md +0 -277
- package/vendor/dragonbox/cmake/dragonboxConfig.cmake +0 -1
- package/vendor/dragonbox/include/dragonbox/dragonbox.h +0 -2674
- package/vendor/dragonbox/include/dragonbox/dragonbox_to_chars.h +0 -108
- package/vendor/dragonbox/other_files/Dragonbox.pdf +0 -0
- package/vendor/dragonbox/other_files/Dragonbox_old.pdf +0 -0
- package/vendor/dragonbox/other_files/milo_benchmark.png +0 -0
- package/vendor/dragonbox/other_files/unknown_win64_vc2019.html +0 -540
- package/vendor/dragonbox/other_files/unknown_win64_vc2019_randomdigit_time.png +0 -0
- package/vendor/dragonbox/source/dragonbox_to_chars.cpp +0 -303
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/CMakeLists.txt +0 -24
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.cpp +0 -238
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.h +0 -95
- package/vendor/dragonbox/subproject/3rdparty/grisu_exact/grisu_exact.h +0 -2666
- package/vendor/dragonbox/subproject/3rdparty/ryu/CMakeLists.txt +0 -16
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/common.h +0 -114
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s.c +0 -509
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_full_table.h +0 -367
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_intrinsics.h +0 -357
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/digit_table.h +0 -35
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s.c +0 -345
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_full_table.h +0 -55
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_intrinsics.h +0 -128
- package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/ryu.h +0 -46
- package/vendor/dragonbox/subproject/3rdparty/schubfach/CMakeLists.txt +0 -22
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.cc +0 -699
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.h +0 -31
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.cc +0 -1354
- package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.h +0 -31
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/example_shaded_plots.m +0 -68
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/license.txt +0 -25
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution.m +0 -92
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution_prctile.m +0 -121
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_histogram_shaded.m +0 -99
- package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_shaded.m +0 -93
- package/vendor/dragonbox/subproject/benchmark/CMakeLists.txt +0 -65
- package/vendor/dragonbox/subproject/benchmark/include/benchmark.h +0 -40
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_benchmarks.m +0 -22
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_digit_benchmark.m +0 -78
- package/vendor/dragonbox/subproject/benchmark/matlab/plot_uniform_benchmark.m +0 -95
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_clang.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_msvc.png +0 -0
- package/vendor/dragonbox/subproject/benchmark/source/benchmark.cpp +0 -238
- package/vendor/dragonbox/subproject/benchmark/source/dragonbox.cpp +0 -30
- package/vendor/dragonbox/subproject/benchmark/source/grisu_exact.cpp +0 -36
- package/vendor/dragonbox/subproject/benchmark/source/ryu.cpp +0 -27
- package/vendor/dragonbox/subproject/benchmark/source/schubfach.cpp +0 -31
- package/vendor/dragonbox/subproject/common/CMakeLists.txt +0 -42
- package/vendor/dragonbox/subproject/common/include/best_rational_approx.h +0 -97
- package/vendor/dragonbox/subproject/common/include/big_uint.h +0 -218
- package/vendor/dragonbox/subproject/common/include/continued_fractions.h +0 -174
- package/vendor/dragonbox/subproject/common/include/good_rational_approx.h +0 -267
- package/vendor/dragonbox/subproject/common/include/random_float.h +0 -182
- package/vendor/dragonbox/subproject/common/include/rational_continued_fractions.h +0 -57
- package/vendor/dragonbox/subproject/common/source/big_uint.cpp +0 -602
- package/vendor/dragonbox/subproject/meta/CMakeLists.txt +0 -41
- package/vendor/dragonbox/subproject/meta/results/binary32_generated_cache.txt +0 -82
- package/vendor/dragonbox/subproject/meta/results/binary64_compressed_cache_error_table.txt +0 -10
- package/vendor/dragonbox/subproject/meta/results/binary64_generated_cache.txt +0 -623
- package/vendor/dragonbox/subproject/meta/source/generate_cache.cpp +0 -126
- package/vendor/dragonbox/subproject/meta/source/live_test.cpp +0 -81
- package/vendor/dragonbox/subproject/meta/source/perf_test.cpp +0 -104
- package/vendor/dragonbox/subproject/meta/source/sandbox.cpp +0 -20
- package/vendor/dragonbox/subproject/test/CMakeLists.txt +0 -70
- package/vendor/dragonbox/subproject/test/results/binary32.csv +0 -255
- package/vendor/dragonbox/subproject/test/results/binary64.csv +0 -2047
- package/vendor/dragonbox/subproject/test/results/plot_required_bits.m +0 -18
- package/vendor/dragonbox/subproject/test/source/test_all_shorter_interval_cases.cpp +0 -88
- package/vendor/dragonbox/subproject/test/source/uniform_random_test.cpp +0 -95
- package/vendor/dragonbox/subproject/test/source/verify_cache_precision.cpp +0 -338
- package/vendor/dragonbox/subproject/test/source/verify_compressed_cache.cpp +0 -154
- package/vendor/dragonbox/subproject/test/source/verify_fast_multiplication.cpp +0 -168
- package/vendor/dragonbox/subproject/test/source/verify_log_computation.cpp +0 -251
- package/vendor/dragonbox/subproject/test/source/verify_magic_division.cpp +0 -113
- package/vendor/miniz/ChangeLog.md +0 -239
- package/vendor/miniz/LICENSE +0 -22
- package/vendor/miniz/examples/example1.c +0 -105
- package/vendor/miniz/examples/example2.c +0 -164
- package/vendor/miniz/examples/example3.c +0 -269
- package/vendor/miniz/examples/example4.c +0 -102
- package/vendor/miniz/examples/example5.c +0 -327
- package/vendor/miniz/examples/example6.c +0 -166
- package/vendor/miniz/miniz.c +0 -7835
- package/vendor/miniz/miniz.h +0 -1422
- package/vendor/miniz/readme.md +0 -46
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_arm64/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_arm64/koffi.lib +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_ia32/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_ia32/koffi.lib +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_x64/koffi.exp +0 -0
- /package/src/koffi/build/{2.3.6-beta.6 → 2.3.7}/koffi_win32_x64/koffi.lib +0 -0
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
// Copyright 2018 Ulf Adams
|
|
2
|
-
//
|
|
3
|
-
// The contents of this file may be used under the terms of the Apache License,
|
|
4
|
-
// Version 2.0.
|
|
5
|
-
//
|
|
6
|
-
// (See accompanying file LICENSE-Apache or copy at
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0)
|
|
8
|
-
//
|
|
9
|
-
// Alternatively, the contents of this file may be used under the terms of
|
|
10
|
-
// the Boost Software License, Version 1.0.
|
|
11
|
-
// (See accompanying file LICENSE-Boost or copy at
|
|
12
|
-
// https://www.boost.org/LICENSE_1_0.txt)
|
|
13
|
-
//
|
|
14
|
-
// Unless required by applicable law or agreed to in writing, this software
|
|
15
|
-
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
// KIND, either express or implied.
|
|
17
|
-
|
|
18
|
-
// Runtime compiler options:
|
|
19
|
-
// -DRYU_DEBUG Generate verbose debugging output to stdout.
|
|
20
|
-
|
|
21
|
-
#include "ryu/ryu.h"
|
|
22
|
-
|
|
23
|
-
#include <assert.h>
|
|
24
|
-
#include <stdbool.h>
|
|
25
|
-
#include <stdint.h>
|
|
26
|
-
#include <stdlib.h>
|
|
27
|
-
#include <string.h>
|
|
28
|
-
#include <limits.h>
|
|
29
|
-
|
|
30
|
-
#ifdef RYU_DEBUG
|
|
31
|
-
#include <stdio.h>
|
|
32
|
-
#endif
|
|
33
|
-
|
|
34
|
-
#include "ryu/common.h"
|
|
35
|
-
#include "ryu/f2s_intrinsics.h"
|
|
36
|
-
#include "ryu/digit_table.h"
|
|
37
|
-
|
|
38
|
-
#define FLOAT_MANTISSA_BITS 23
|
|
39
|
-
#define FLOAT_EXPONENT_BITS 8
|
|
40
|
-
#define FLOAT_BIAS 127
|
|
41
|
-
|
|
42
|
-
// A floating decimal representing m * 10^e.
|
|
43
|
-
typedef struct floating_decimal_32 {
|
|
44
|
-
uint32_t mantissa;
|
|
45
|
-
// Decimal exponent's range is -45 to 38
|
|
46
|
-
// inclusive, and can fit in a short if needed.
|
|
47
|
-
int32_t exponent;
|
|
48
|
-
} floating_decimal_32;
|
|
49
|
-
|
|
50
|
-
static inline floating_decimal_32 f2d(const uint32_t ieeeMantissa, const uint32_t ieeeExponent) {
|
|
51
|
-
int32_t e2;
|
|
52
|
-
uint32_t m2;
|
|
53
|
-
if (ieeeExponent == 0) {
|
|
54
|
-
// We subtract 2 so that the bounds computation has 2 additional bits.
|
|
55
|
-
e2 = 1 - FLOAT_BIAS - FLOAT_MANTISSA_BITS - 2;
|
|
56
|
-
m2 = ieeeMantissa;
|
|
57
|
-
} else {
|
|
58
|
-
e2 = (int32_t) ieeeExponent - FLOAT_BIAS - FLOAT_MANTISSA_BITS - 2;
|
|
59
|
-
m2 = (1u << FLOAT_MANTISSA_BITS) | ieeeMantissa;
|
|
60
|
-
}
|
|
61
|
-
const bool even = (m2 & 1) == 0;
|
|
62
|
-
const bool acceptBounds = even;
|
|
63
|
-
|
|
64
|
-
#ifdef RYU_DEBUG
|
|
65
|
-
printf("-> %u * 2^%d\n", m2, e2 + 2);
|
|
66
|
-
#endif
|
|
67
|
-
|
|
68
|
-
// Step 2: Determine the interval of valid decimal representations.
|
|
69
|
-
const uint32_t mv = 4 * m2;
|
|
70
|
-
const uint32_t mp = 4 * m2 + 2;
|
|
71
|
-
// Implicit bool -> int conversion. True is 1, false is 0.
|
|
72
|
-
const uint32_t mmShift = ieeeMantissa != 0 || ieeeExponent <= 1;
|
|
73
|
-
const uint32_t mm = 4 * m2 - 1 - mmShift;
|
|
74
|
-
|
|
75
|
-
// Step 3: Convert to a decimal power base using 64-bit arithmetic.
|
|
76
|
-
uint32_t vr, vp, vm;
|
|
77
|
-
int32_t e10;
|
|
78
|
-
bool vmIsTrailingZeros = false;
|
|
79
|
-
bool vrIsTrailingZeros = false;
|
|
80
|
-
uint8_t lastRemovedDigit = 0;
|
|
81
|
-
if (e2 >= 0) {
|
|
82
|
-
const uint32_t q = log10Pow2(e2);
|
|
83
|
-
e10 = (int32_t) q;
|
|
84
|
-
const int32_t k = FLOAT_POW5_INV_BITCOUNT + pow5bits((int32_t) q) - 1;
|
|
85
|
-
const int32_t i = -e2 + (int32_t) q + k;
|
|
86
|
-
vr = mulPow5InvDivPow2(mv, q, i);
|
|
87
|
-
vp = mulPow5InvDivPow2(mp, q, i);
|
|
88
|
-
vm = mulPow5InvDivPow2(mm, q, i);
|
|
89
|
-
#ifdef RYU_DEBUG
|
|
90
|
-
printf("%u * 2^%d / 10^%u\n", mv, e2, q);
|
|
91
|
-
printf("V+=%u\nV =%u\nV-=%u\n", vp, vr, vm);
|
|
92
|
-
#endif
|
|
93
|
-
if (q != 0 && (vp - 1) / 10 <= vm / 10) {
|
|
94
|
-
// We need to know one removed digit even if we are not going to loop below. We could use
|
|
95
|
-
// q = X - 1 above, except that would require 33 bits for the result, and we've found that
|
|
96
|
-
// 32-bit arithmetic is faster even on 64-bit machines.
|
|
97
|
-
const int32_t l = FLOAT_POW5_INV_BITCOUNT + pow5bits((int32_t) (q - 1)) - 1;
|
|
98
|
-
lastRemovedDigit = (uint8_t) (mulPow5InvDivPow2(mv, q - 1, -e2 + (int32_t) q - 1 + l) % 10);
|
|
99
|
-
}
|
|
100
|
-
if (q <= 9) {
|
|
101
|
-
// The largest power of 5 that fits in 24 bits is 5^10, but q <= 9 seems to be safe as well.
|
|
102
|
-
// Only one of mp, mv, and mm can be a multiple of 5, if any.
|
|
103
|
-
if (mv % 5 == 0) {
|
|
104
|
-
vrIsTrailingZeros = multipleOfPowerOf5_32(mv, q);
|
|
105
|
-
} else if (acceptBounds) {
|
|
106
|
-
vmIsTrailingZeros = multipleOfPowerOf5_32(mm, q);
|
|
107
|
-
} else {
|
|
108
|
-
vp -= multipleOfPowerOf5_32(mp, q);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
const uint32_t q = log10Pow5(-e2);
|
|
113
|
-
e10 = (int32_t) q + e2;
|
|
114
|
-
const int32_t i = -e2 - (int32_t) q;
|
|
115
|
-
const int32_t k = pow5bits(i) - FLOAT_POW5_BITCOUNT;
|
|
116
|
-
int32_t j = (int32_t) q - k;
|
|
117
|
-
vr = mulPow5divPow2(mv, (uint32_t) i, j);
|
|
118
|
-
vp = mulPow5divPow2(mp, (uint32_t) i, j);
|
|
119
|
-
vm = mulPow5divPow2(mm, (uint32_t) i, j);
|
|
120
|
-
#ifdef RYU_DEBUG
|
|
121
|
-
printf("%u * 5^%d / 10^%u\n", mv, -e2, q);
|
|
122
|
-
printf("%u %d %d %d\n", q, i, k, j);
|
|
123
|
-
printf("V+=%u\nV =%u\nV-=%u\n", vp, vr, vm);
|
|
124
|
-
#endif
|
|
125
|
-
if (q != 0 && (vp - 1) / 10 <= vm / 10) {
|
|
126
|
-
j = (int32_t) q - 1 - (pow5bits(i + 1) - FLOAT_POW5_BITCOUNT);
|
|
127
|
-
lastRemovedDigit = (uint8_t) (mulPow5divPow2(mv, (uint32_t) (i + 1), j) % 10);
|
|
128
|
-
}
|
|
129
|
-
if (q <= 1) {
|
|
130
|
-
// {vr,vp,vm} is trailing zeros if {mv,mp,mm} has at least q trailing 0 bits.
|
|
131
|
-
// mv = 4 * m2, so it always has at least two trailing 0 bits.
|
|
132
|
-
vrIsTrailingZeros = true;
|
|
133
|
-
if (acceptBounds) {
|
|
134
|
-
// mm = mv - 1 - mmShift, so it has 1 trailing 0 bit iff mmShift == 1.
|
|
135
|
-
vmIsTrailingZeros = mmShift == 1;
|
|
136
|
-
} else {
|
|
137
|
-
// mp = mv + 2, so it always has at least one trailing 0 bit.
|
|
138
|
-
--vp;
|
|
139
|
-
}
|
|
140
|
-
} else if (q < 31) { // TODO(ulfjack): Use a tighter bound here.
|
|
141
|
-
vrIsTrailingZeros = multipleOfPowerOf2_32(mv, q - 1);
|
|
142
|
-
#ifdef RYU_DEBUG
|
|
143
|
-
printf("vr is trailing zeros=%s\n", vrIsTrailingZeros ? "true" : "false");
|
|
144
|
-
#endif
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
#ifdef RYU_DEBUG
|
|
148
|
-
printf("e10=%d\n", e10);
|
|
149
|
-
printf("V+=%u\nV =%u\nV-=%u\n", vp, vr, vm);
|
|
150
|
-
printf("vm is trailing zeros=%s\n", vmIsTrailingZeros ? "true" : "false");
|
|
151
|
-
printf("vr is trailing zeros=%s\n", vrIsTrailingZeros ? "true" : "false");
|
|
152
|
-
#endif
|
|
153
|
-
|
|
154
|
-
// Step 4: Find the shortest decimal representation in the interval of valid representations.
|
|
155
|
-
int32_t removed = 0;
|
|
156
|
-
uint32_t output;
|
|
157
|
-
if (vmIsTrailingZeros || vrIsTrailingZeros) {
|
|
158
|
-
// General case, which happens rarely (~4.0%).
|
|
159
|
-
while (vp / 10 > vm / 10) {
|
|
160
|
-
#ifdef __clang__ // https://bugs.llvm.org/show_bug.cgi?id=23106
|
|
161
|
-
// The compiler does not realize that vm % 10 can be computed from vm / 10
|
|
162
|
-
// as vm - (vm / 10) * 10.
|
|
163
|
-
vmIsTrailingZeros &= vm - (vm / 10) * 10 == 0;
|
|
164
|
-
#else
|
|
165
|
-
vmIsTrailingZeros &= vm % 10 == 0;
|
|
166
|
-
#endif
|
|
167
|
-
vrIsTrailingZeros &= lastRemovedDigit == 0;
|
|
168
|
-
lastRemovedDigit = (uint8_t) (vr % 10);
|
|
169
|
-
vr /= 10;
|
|
170
|
-
vp /= 10;
|
|
171
|
-
vm /= 10;
|
|
172
|
-
++removed;
|
|
173
|
-
}
|
|
174
|
-
#ifdef RYU_DEBUG
|
|
175
|
-
printf("V+=%u\nV =%u\nV-=%u\n", vp, vr, vm);
|
|
176
|
-
printf("d-10=%s\n", vmIsTrailingZeros ? "true" : "false");
|
|
177
|
-
#endif
|
|
178
|
-
if (vmIsTrailingZeros) {
|
|
179
|
-
while (vm % 10 == 0) {
|
|
180
|
-
vrIsTrailingZeros &= lastRemovedDigit == 0;
|
|
181
|
-
lastRemovedDigit = (uint8_t) (vr % 10);
|
|
182
|
-
vr /= 10;
|
|
183
|
-
vp /= 10;
|
|
184
|
-
vm /= 10;
|
|
185
|
-
++removed;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
#ifdef RYU_DEBUG
|
|
189
|
-
printf("%u %d\n", vr, lastRemovedDigit);
|
|
190
|
-
printf("vr is trailing zeros=%s\n", vrIsTrailingZeros ? "true" : "false");
|
|
191
|
-
#endif
|
|
192
|
-
if (vrIsTrailingZeros && lastRemovedDigit == 5 && vr % 2 == 0) {
|
|
193
|
-
// Round even if the exact number is .....50..0.
|
|
194
|
-
lastRemovedDigit = 4;
|
|
195
|
-
}
|
|
196
|
-
// We need to take vr + 1 if vr is outside bounds or we need to round up.
|
|
197
|
-
output = vr + ((vr == vm && (!acceptBounds || !vmIsTrailingZeros)) || lastRemovedDigit >= 5);
|
|
198
|
-
} else {
|
|
199
|
-
// Specialized for the common case (~96.0%). Percentages below are relative to this.
|
|
200
|
-
// Loop iterations below (approximately):
|
|
201
|
-
// 0: 13.6%, 1: 70.7%, 2: 14.1%, 3: 1.39%, 4: 0.14%, 5+: 0.01%
|
|
202
|
-
while (vp / 10 > vm / 10) {
|
|
203
|
-
lastRemovedDigit = (uint8_t) (vr % 10);
|
|
204
|
-
vr /= 10;
|
|
205
|
-
vp /= 10;
|
|
206
|
-
vm /= 10;
|
|
207
|
-
++removed;
|
|
208
|
-
}
|
|
209
|
-
#ifdef RYU_DEBUG
|
|
210
|
-
printf("%u %d\n", vr, lastRemovedDigit);
|
|
211
|
-
printf("vr is trailing zeros=%s\n", vrIsTrailingZeros ? "true" : "false");
|
|
212
|
-
#endif
|
|
213
|
-
// We need to take vr + 1 if vr is outside bounds or we need to round up.
|
|
214
|
-
output = vr + (vr == vm || lastRemovedDigit >= 5);
|
|
215
|
-
}
|
|
216
|
-
const int32_t exp = e10 + removed;
|
|
217
|
-
|
|
218
|
-
#ifdef RYU_DEBUG
|
|
219
|
-
printf("V+=%u\nV =%u\nV-=%u\n", vp, vr, vm);
|
|
220
|
-
printf("O=%u\n", output);
|
|
221
|
-
printf("EXP=%d\n", exp);
|
|
222
|
-
#endif
|
|
223
|
-
|
|
224
|
-
floating_decimal_32 fd;
|
|
225
|
-
fd.exponent = exp;
|
|
226
|
-
fd.mantissa = output;
|
|
227
|
-
return fd;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
static inline int to_chars(const floating_decimal_32 v, const bool sign, char* const result) {
|
|
231
|
-
// Step 5: Print the decimal representation.
|
|
232
|
-
int index = 0;
|
|
233
|
-
if (sign) {
|
|
234
|
-
result[index++] = '-';
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
uint32_t output = v.mantissa;
|
|
238
|
-
const uint32_t olength = decimalLength9(output);
|
|
239
|
-
|
|
240
|
-
#ifdef RYU_DEBUG
|
|
241
|
-
printf("DIGITS=%u\n", v.mantissa);
|
|
242
|
-
printf("OLEN=%u\n", olength);
|
|
243
|
-
printf("EXP=%u\n", v.exponent + olength);
|
|
244
|
-
#endif
|
|
245
|
-
|
|
246
|
-
// Print the decimal digits.
|
|
247
|
-
// The following code is equivalent to:
|
|
248
|
-
// for (uint32_t i = 0; i < olength - 1; ++i) {
|
|
249
|
-
// const uint32_t c = output % 10; output /= 10;
|
|
250
|
-
// result[index + olength - i] = (char) ('0' + c);
|
|
251
|
-
// }
|
|
252
|
-
// result[index] = '0' + output % 10;
|
|
253
|
-
uint32_t i = 0;
|
|
254
|
-
while (output >= 10000) {
|
|
255
|
-
#ifdef __clang__ // https://bugs.llvm.org/show_bug.cgi?id=38217
|
|
256
|
-
const uint32_t c = output - 10000 * (output / 10000);
|
|
257
|
-
#else
|
|
258
|
-
const uint32_t c = output % 10000;
|
|
259
|
-
#endif
|
|
260
|
-
output /= 10000;
|
|
261
|
-
const uint32_t c0 = (c % 100) << 1;
|
|
262
|
-
const uint32_t c1 = (c / 100) << 1;
|
|
263
|
-
memcpy(result + index + olength - i - 1, DIGIT_TABLE + c0, 2);
|
|
264
|
-
memcpy(result + index + olength - i - 3, DIGIT_TABLE + c1, 2);
|
|
265
|
-
i += 4;
|
|
266
|
-
}
|
|
267
|
-
if (output >= 100) {
|
|
268
|
-
const uint32_t c = (output % 100) << 1;
|
|
269
|
-
output /= 100;
|
|
270
|
-
memcpy(result + index + olength - i - 1, DIGIT_TABLE + c, 2);
|
|
271
|
-
i += 2;
|
|
272
|
-
}
|
|
273
|
-
if (output >= 10) {
|
|
274
|
-
const uint32_t c = output << 1;
|
|
275
|
-
// We can't use memcpy here: the decimal dot goes between these two digits.
|
|
276
|
-
result[index + olength - i] = DIGIT_TABLE[c + 1];
|
|
277
|
-
result[index] = DIGIT_TABLE[c];
|
|
278
|
-
} else {
|
|
279
|
-
result[index] = (char) ('0' + output);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
// Print decimal point if needed.
|
|
283
|
-
if (olength > 1) {
|
|
284
|
-
result[index + 1] = '.';
|
|
285
|
-
index += olength + 1;
|
|
286
|
-
} else {
|
|
287
|
-
++index;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// Print the exponent.
|
|
291
|
-
result[index++] = 'E';
|
|
292
|
-
int32_t exp = v.exponent + (int32_t) olength - 1;
|
|
293
|
-
if (exp < 0) {
|
|
294
|
-
result[index++] = '-';
|
|
295
|
-
exp = -exp;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (exp >= 10) {
|
|
299
|
-
memcpy(result + index, DIGIT_TABLE + 2 * exp, 2);
|
|
300
|
-
index += 2;
|
|
301
|
-
} else {
|
|
302
|
-
result[index++] = (char) ('0' + exp);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return index;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
int f2s_buffered_n(float f, char* result) {
|
|
309
|
-
// Step 1: Decode the floating-point number, and unify normalized and subnormal cases.
|
|
310
|
-
const uint32_t bits = float_to_bits(f);
|
|
311
|
-
|
|
312
|
-
#ifdef RYU_DEBUG
|
|
313
|
-
printf("IN=");
|
|
314
|
-
for (int32_t bit = 31; bit >= 0; --bit) {
|
|
315
|
-
printf("%u", (bits >> bit) & 1);
|
|
316
|
-
}
|
|
317
|
-
printf("\n");
|
|
318
|
-
#endif
|
|
319
|
-
|
|
320
|
-
// Decode bits into sign, mantissa, and exponent.
|
|
321
|
-
const bool ieeeSign = ((bits >> (FLOAT_MANTISSA_BITS + FLOAT_EXPONENT_BITS)) & 1) != 0;
|
|
322
|
-
const uint32_t ieeeMantissa = bits & ((1u << FLOAT_MANTISSA_BITS) - 1);
|
|
323
|
-
const uint32_t ieeeExponent = (bits >> FLOAT_MANTISSA_BITS) & ((1u << FLOAT_EXPONENT_BITS) - 1);
|
|
324
|
-
|
|
325
|
-
// Case distinction; exit early for the easy cases.
|
|
326
|
-
if (ieeeExponent == ((1u << FLOAT_EXPONENT_BITS) - 1u) || (ieeeExponent == 0 && ieeeMantissa == 0)) {
|
|
327
|
-
return copy_special_str(result, ieeeSign, ieeeExponent, ieeeMantissa);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
const floating_decimal_32 v = f2d(ieeeMantissa, ieeeExponent);
|
|
331
|
-
return to_chars(v, ieeeSign, result);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
void f2s_buffered(float f, char* result) {
|
|
335
|
-
const int index = f2s_buffered_n(f, result);
|
|
336
|
-
|
|
337
|
-
// Terminate the string.
|
|
338
|
-
result[index] = '\0';
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
char* f2s(float f) {
|
|
342
|
-
char* const result = (char*) malloc(16);
|
|
343
|
-
f2s_buffered(f, result);
|
|
344
|
-
return result;
|
|
345
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// Copyright 2018 Ulf Adams
|
|
2
|
-
//
|
|
3
|
-
// The contents of this file may be used under the terms of the Apache License,
|
|
4
|
-
// Version 2.0.
|
|
5
|
-
//
|
|
6
|
-
// (See accompanying file LICENSE-Apache or copy at
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0)
|
|
8
|
-
//
|
|
9
|
-
// Alternatively, the contents of this file may be used under the terms of
|
|
10
|
-
// the Boost Software License, Version 1.0.
|
|
11
|
-
// (See accompanying file LICENSE-Boost or copy at
|
|
12
|
-
// https://www.boost.org/LICENSE_1_0.txt)
|
|
13
|
-
//
|
|
14
|
-
// Unless required by applicable law or agreed to in writing, this software
|
|
15
|
-
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
// KIND, either express or implied.
|
|
17
|
-
#ifndef RYU_F2S_FULL_TABLE_H
|
|
18
|
-
#define RYU_F2S_FULL_TABLE_H
|
|
19
|
-
|
|
20
|
-
// This table is generated by PrintFloatLookupTable.
|
|
21
|
-
#define FLOAT_POW5_INV_BITCOUNT 59
|
|
22
|
-
#define FLOAT_POW5_BITCOUNT 61
|
|
23
|
-
|
|
24
|
-
static uint64_t FLOAT_POW5_INV_SPLIT[55] = {
|
|
25
|
-
576460752303423489u, 461168601842738791u, 368934881474191033u, 295147905179352826u,
|
|
26
|
-
472236648286964522u, 377789318629571618u, 302231454903657294u, 483570327845851670u,
|
|
27
|
-
386856262276681336u, 309485009821345069u, 495176015714152110u, 396140812571321688u,
|
|
28
|
-
316912650057057351u, 507060240091291761u, 405648192073033409u, 324518553658426727u,
|
|
29
|
-
519229685853482763u, 415383748682786211u, 332306998946228969u, 531691198313966350u,
|
|
30
|
-
425352958651173080u, 340282366920938464u, 544451787073501542u, 435561429658801234u,
|
|
31
|
-
348449143727040987u, 557518629963265579u, 446014903970612463u, 356811923176489971u,
|
|
32
|
-
570899077082383953u, 456719261665907162u, 365375409332725730u, 292300327466180584u,
|
|
33
|
-
467680523945888934u, 374144419156711148u, 299315535325368918u, 478904856520590269u,
|
|
34
|
-
383123885216472215u, 306499108173177772u, 490398573077084435u, 392318858461667548u,
|
|
35
|
-
313855086769334039u, 502168138830934462u, 401734511064747569u, 321387608851798056u,
|
|
36
|
-
514220174162876889u, 411376139330301511u, 329100911464241209u, 526561458342785934u,
|
|
37
|
-
421249166674228747u, 336999333339382998u, 539198933343012796u, 431359146674410237u,
|
|
38
|
-
345087317339528190u, 552139707743245103u, 441711766194596083u
|
|
39
|
-
};
|
|
40
|
-
static const uint64_t FLOAT_POW5_SPLIT[47] = {
|
|
41
|
-
1152921504606846976u, 1441151880758558720u, 1801439850948198400u, 2251799813685248000u,
|
|
42
|
-
1407374883553280000u, 1759218604441600000u, 2199023255552000000u, 1374389534720000000u,
|
|
43
|
-
1717986918400000000u, 2147483648000000000u, 1342177280000000000u, 1677721600000000000u,
|
|
44
|
-
2097152000000000000u, 1310720000000000000u, 1638400000000000000u, 2048000000000000000u,
|
|
45
|
-
1280000000000000000u, 1600000000000000000u, 2000000000000000000u, 1250000000000000000u,
|
|
46
|
-
1562500000000000000u, 1953125000000000000u, 1220703125000000000u, 1525878906250000000u,
|
|
47
|
-
1907348632812500000u, 1192092895507812500u, 1490116119384765625u, 1862645149230957031u,
|
|
48
|
-
1164153218269348144u, 1455191522836685180u, 1818989403545856475u, 2273736754432320594u,
|
|
49
|
-
1421085471520200371u, 1776356839400250464u, 2220446049250313080u, 1387778780781445675u,
|
|
50
|
-
1734723475976807094u, 2168404344971008868u, 1355252715606880542u, 1694065894508600678u,
|
|
51
|
-
2117582368135750847u, 1323488980084844279u, 1654361225106055349u, 2067951531382569187u,
|
|
52
|
-
1292469707114105741u, 1615587133892632177u, 2019483917365790221u
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
#endif // RYU_F2S_FULL_TABLE_H
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// Copyright 2018 Ulf Adams
|
|
2
|
-
//
|
|
3
|
-
// The contents of this file may be used under the terms of the Apache License,
|
|
4
|
-
// Version 2.0.
|
|
5
|
-
//
|
|
6
|
-
// (See accompanying file LICENSE-Apache or copy at
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0)
|
|
8
|
-
//
|
|
9
|
-
// Alternatively, the contents of this file may be used under the terms of
|
|
10
|
-
// the Boost Software License, Version 1.0.
|
|
11
|
-
// (See accompanying file LICENSE-Boost or copy at
|
|
12
|
-
// https://www.boost.org/LICENSE_1_0.txt)
|
|
13
|
-
//
|
|
14
|
-
// Unless required by applicable law or agreed to in writing, this software
|
|
15
|
-
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
// KIND, either express or implied.
|
|
17
|
-
#ifndef RYU_F2S_INTRINSICS_H
|
|
18
|
-
#define RYU_F2S_INTRINSICS_H
|
|
19
|
-
|
|
20
|
-
// Defines RYU_32_BIT_PLATFORM if applicable.
|
|
21
|
-
#include "ryu/common.h"
|
|
22
|
-
|
|
23
|
-
#if defined(RYU_FLOAT_FULL_TABLE)
|
|
24
|
-
|
|
25
|
-
#include "ryu/f2s_full_table.h"
|
|
26
|
-
|
|
27
|
-
#else
|
|
28
|
-
|
|
29
|
-
#if defined(RYU_OPTIMIZE_SIZE)
|
|
30
|
-
#include "ryu/d2s_small_table.h"
|
|
31
|
-
#else
|
|
32
|
-
#include "ryu/d2s_full_table.h"
|
|
33
|
-
#endif
|
|
34
|
-
#define FLOAT_POW5_INV_BITCOUNT (DOUBLE_POW5_INV_BITCOUNT - 64)
|
|
35
|
-
#define FLOAT_POW5_BITCOUNT (DOUBLE_POW5_BITCOUNT - 64)
|
|
36
|
-
|
|
37
|
-
#endif
|
|
38
|
-
|
|
39
|
-
static inline uint32_t pow5factor_32(uint32_t value) {
|
|
40
|
-
uint32_t count = 0;
|
|
41
|
-
for (;;) {
|
|
42
|
-
assert(value != 0);
|
|
43
|
-
const uint32_t q = value / 5;
|
|
44
|
-
const uint32_t r = value % 5;
|
|
45
|
-
if (r != 0) {
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
value = q;
|
|
49
|
-
++count;
|
|
50
|
-
}
|
|
51
|
-
return count;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Returns true if value is divisible by 5^p.
|
|
55
|
-
static inline bool multipleOfPowerOf5_32(const uint32_t value, const uint32_t p) {
|
|
56
|
-
return pow5factor_32(value) >= p;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Returns true if value is divisible by 2^p.
|
|
60
|
-
static inline bool multipleOfPowerOf2_32(const uint32_t value, const uint32_t p) {
|
|
61
|
-
// __builtin_ctz doesn't appear to be faster here.
|
|
62
|
-
return (value & ((1u << p) - 1)) == 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// It seems to be slightly faster to avoid uint128_t here, although the
|
|
66
|
-
// generated code for uint128_t looks slightly nicer.
|
|
67
|
-
static inline uint32_t mulShift32(const uint32_t m, const uint64_t factor, const int32_t shift) {
|
|
68
|
-
assert(shift > 32);
|
|
69
|
-
|
|
70
|
-
// The casts here help MSVC to avoid calls to the __allmul library
|
|
71
|
-
// function.
|
|
72
|
-
const uint32_t factorLo = (uint32_t)(factor);
|
|
73
|
-
const uint32_t factorHi = (uint32_t)(factor >> 32);
|
|
74
|
-
const uint64_t bits0 = (uint64_t)m * factorLo;
|
|
75
|
-
const uint64_t bits1 = (uint64_t)m * factorHi;
|
|
76
|
-
|
|
77
|
-
#if defined(RYU_32_BIT_PLATFORM)
|
|
78
|
-
// On 32-bit platforms we can avoid a 64-bit shift-right since we only
|
|
79
|
-
// need the upper 32 bits of the result and the shift value is > 32.
|
|
80
|
-
const uint32_t bits0Hi = (uint32_t)(bits0 >> 32);
|
|
81
|
-
uint32_t bits1Lo = (uint32_t)(bits1);
|
|
82
|
-
uint32_t bits1Hi = (uint32_t)(bits1 >> 32);
|
|
83
|
-
bits1Lo += bits0Hi;
|
|
84
|
-
bits1Hi += (bits1Lo < bits0Hi);
|
|
85
|
-
if (shift >= 64) {
|
|
86
|
-
// s2f can call this with a shift value >= 64, which we have to handle.
|
|
87
|
-
// This could now be slower than the !defined(RYU_32_BIT_PLATFORM) case.
|
|
88
|
-
return (uint32_t)(bits1Hi >> (shift - 64));
|
|
89
|
-
} else {
|
|
90
|
-
const int32_t s = shift - 32;
|
|
91
|
-
return (bits1Hi << (32 - s)) | (bits1Lo >> s);
|
|
92
|
-
}
|
|
93
|
-
#else // RYU_32_BIT_PLATFORM
|
|
94
|
-
const uint64_t sum = (bits0 >> 32) + bits1;
|
|
95
|
-
const uint64_t shiftedSum = sum >> (shift - 32);
|
|
96
|
-
assert(shiftedSum <= UINT32_MAX);
|
|
97
|
-
return (uint32_t) shiftedSum;
|
|
98
|
-
#endif // RYU_32_BIT_PLATFORM
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
static inline uint32_t mulPow5InvDivPow2(const uint32_t m, const uint32_t q, const int32_t j) {
|
|
102
|
-
#if defined(RYU_FLOAT_FULL_TABLE)
|
|
103
|
-
return mulShift32(m, FLOAT_POW5_INV_SPLIT[q], j);
|
|
104
|
-
#elif defined(RYU_OPTIMIZE_SIZE)
|
|
105
|
-
// The inverse multipliers are defined as [2^x / 5^y] + 1; the upper 64 bits from the double lookup
|
|
106
|
-
// table are the correct bits for [2^x / 5^y], so we have to add 1 here. Note that we rely on the
|
|
107
|
-
// fact that the added 1 that's already stored in the table never overflows into the upper 64 bits.
|
|
108
|
-
uint64_t pow5[2];
|
|
109
|
-
double_computeInvPow5(q, pow5);
|
|
110
|
-
return mulShift32(m, pow5[1] + 1, j);
|
|
111
|
-
#else
|
|
112
|
-
return mulShift32(m, DOUBLE_POW5_INV_SPLIT[q][1] + 1, j);
|
|
113
|
-
#endif
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
static inline uint32_t mulPow5divPow2(const uint32_t m, const uint32_t i, const int32_t j) {
|
|
117
|
-
#if defined(RYU_FLOAT_FULL_TABLE)
|
|
118
|
-
return mulShift32(m, FLOAT_POW5_SPLIT[i], j);
|
|
119
|
-
#elif defined(RYU_OPTIMIZE_SIZE)
|
|
120
|
-
uint64_t pow5[2];
|
|
121
|
-
double_computePow5(i, pow5);
|
|
122
|
-
return mulShift32(m, pow5[1], j);
|
|
123
|
-
#else
|
|
124
|
-
return mulShift32(m, DOUBLE_POW5_SPLIT[i][1], j);
|
|
125
|
-
#endif
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
#endif // RYU_F2S_INTRINSICS_H
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Copyright 2018 Ulf Adams
|
|
2
|
-
//
|
|
3
|
-
// The contents of this file may be used under the terms of the Apache License,
|
|
4
|
-
// Version 2.0.
|
|
5
|
-
//
|
|
6
|
-
// (See accompanying file LICENSE-Apache or copy at
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0)
|
|
8
|
-
//
|
|
9
|
-
// Alternatively, the contents of this file may be used under the terms of
|
|
10
|
-
// the Boost Software License, Version 1.0.
|
|
11
|
-
// (See accompanying file LICENSE-Boost or copy at
|
|
12
|
-
// https://www.boost.org/LICENSE_1_0.txt)
|
|
13
|
-
//
|
|
14
|
-
// Unless required by applicable law or agreed to in writing, this software
|
|
15
|
-
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
// KIND, either express or implied.
|
|
17
|
-
#ifndef RYU_H
|
|
18
|
-
#define RYU_H
|
|
19
|
-
|
|
20
|
-
#ifdef __cplusplus
|
|
21
|
-
extern "C" {
|
|
22
|
-
#endif
|
|
23
|
-
|
|
24
|
-
#include <inttypes.h>
|
|
25
|
-
|
|
26
|
-
int d2s_buffered_n(double f, char* result);
|
|
27
|
-
void d2s_buffered(double f, char* result);
|
|
28
|
-
char* d2s(double f);
|
|
29
|
-
|
|
30
|
-
int f2s_buffered_n(float f, char* result);
|
|
31
|
-
void f2s_buffered(float f, char* result);
|
|
32
|
-
char* f2s(float f);
|
|
33
|
-
|
|
34
|
-
int d2fixed_buffered_n(double d, uint32_t precision, char* result);
|
|
35
|
-
void d2fixed_buffered(double d, uint32_t precision, char* result);
|
|
36
|
-
char* d2fixed(double d, uint32_t precision);
|
|
37
|
-
|
|
38
|
-
int d2exp_buffered_n(double d, uint32_t precision, char* result);
|
|
39
|
-
void d2exp_buffered(double d, uint32_t precision, char* result);
|
|
40
|
-
char* d2exp(double d, uint32_t precision);
|
|
41
|
-
|
|
42
|
-
#ifdef __cplusplus
|
|
43
|
-
}
|
|
44
|
-
#endif
|
|
45
|
-
|
|
46
|
-
#endif // RYU_H
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
|
2
|
-
|
|
3
|
-
project(schubfach LANGUAGES CXX)
|
|
4
|
-
|
|
5
|
-
add_library(schubfach STATIC
|
|
6
|
-
schubfach_32.cc schubfach_32.h schubfach_64.cc schubfach_64.h)
|
|
7
|
-
add_library(schubfach::schubfach ALIAS schubfach)
|
|
8
|
-
|
|
9
|
-
target_compile_features(schubfach PUBLIC cxx_std_17)
|
|
10
|
-
|
|
11
|
-
target_include_directories(schubfach
|
|
12
|
-
PUBLIC
|
|
13
|
-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>)
|
|
14
|
-
|
|
15
|
-
# ---- MSVC Specifics ----
|
|
16
|
-
if (MSVC)
|
|
17
|
-
# No need to not generate PDB
|
|
18
|
-
# /permissive- should be the default
|
|
19
|
-
target_compile_options(schubfach PUBLIC
|
|
20
|
-
/Zi /permissive-
|
|
21
|
-
$<$<CONFIG:Release>:/GL>)
|
|
22
|
-
endif()
|