koffi 2.3.6 → 2.3.8

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.
Files changed (280) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +2 -2
  3. package/src/cnoke/cnoke.js +3 -7
  4. package/src/cnoke/src/builder.js +7 -4
  5. package/src/cnoke/src/index.js +2 -2
  6. package/src/koffi/build/2.3.8/koffi_darwin_arm64/koffi.node +0 -0
  7. package/src/koffi/build/2.3.8/koffi_darwin_x64/koffi.node +0 -0
  8. package/src/koffi/build/2.3.8/koffi_freebsd_arm64/koffi.node +0 -0
  9. package/src/koffi/build/2.3.8/koffi_freebsd_ia32/koffi.node +0 -0
  10. package/src/koffi/build/2.3.8/koffi_freebsd_x64/koffi.node +0 -0
  11. package/src/koffi/build/2.3.8/koffi_linux_arm32hf/koffi.node +0 -0
  12. package/src/koffi/build/2.3.8/koffi_linux_arm64/koffi.node +0 -0
  13. package/src/koffi/build/2.3.8/koffi_linux_ia32/koffi.node +0 -0
  14. package/src/koffi/build/2.3.8/koffi_linux_riscv64hf64/koffi.node +0 -0
  15. package/src/koffi/build/2.3.8/koffi_linux_x64/koffi.node +0 -0
  16. package/src/koffi/build/2.3.8/koffi_openbsd_ia32/koffi.node +0 -0
  17. package/src/koffi/build/2.3.8/koffi_openbsd_x64/koffi.node +0 -0
  18. package/src/koffi/build/2.3.8/koffi_win32_arm64/koffi.node +0 -0
  19. package/src/koffi/build/2.3.8/koffi_win32_ia32/koffi.node +0 -0
  20. package/src/koffi/build/2.3.8/koffi_win32_x64/koffi.node +0 -0
  21. package/src/koffi/src/abi_arm64.cc +8 -2
  22. package/src/koffi/src/abi_x64_win.cc +8 -2
  23. package/src/koffi/src/abi_x86.cc +8 -2
  24. package/src/koffi/src/ffi.cc +3 -22
  25. package/src/koffi/src/index.d.ts +1 -1
  26. package/src/koffi/src/index.js +1 -0
  27. package/src/koffi/src/win32.hh +10 -4
  28. package/src/koffi/build/2.3.6/koffi_darwin_arm64/koffi.node +0 -0
  29. package/src/koffi/build/2.3.6/koffi_darwin_x64/koffi.node +0 -0
  30. package/src/koffi/build/2.3.6/koffi_freebsd_arm64/koffi.node +0 -0
  31. package/src/koffi/build/2.3.6/koffi_freebsd_ia32/koffi.node +0 -0
  32. package/src/koffi/build/2.3.6/koffi_freebsd_x64/koffi.node +0 -0
  33. package/src/koffi/build/2.3.6/koffi_linux_arm32hf/koffi.node +0 -0
  34. package/src/koffi/build/2.3.6/koffi_linux_arm64/koffi.node +0 -0
  35. package/src/koffi/build/2.3.6/koffi_linux_ia32/koffi.node +0 -0
  36. package/src/koffi/build/2.3.6/koffi_linux_riscv64hf64/koffi.node +0 -0
  37. package/src/koffi/build/2.3.6/koffi_linux_x64/koffi.node +0 -0
  38. package/src/koffi/build/2.3.6/koffi_openbsd_ia32/koffi.node +0 -0
  39. package/src/koffi/build/2.3.6/koffi_openbsd_x64/koffi.node +0 -0
  40. package/src/koffi/build/2.3.6/koffi_win32_arm64/koffi.node +0 -0
  41. package/src/koffi/build/2.3.6/koffi_win32_arm64/koffi.pdb +0 -0
  42. package/src/koffi/build/2.3.6/koffi_win32_ia32/koffi.node +0 -0
  43. package/src/koffi/build/2.3.6/koffi_win32_ia32/koffi.pdb +0 -0
  44. package/src/koffi/build/2.3.6/koffi_win32_x64/koffi.node +0 -0
  45. package/src/koffi/build/2.3.6/koffi_win32_x64/koffi.pdb +0 -0
  46. package/vendor/brotli/BUILD +0 -144
  47. package/vendor/brotli/CMakeLists.txt +0 -421
  48. package/vendor/brotli/CONTRIBUTING.md +0 -27
  49. package/vendor/brotli/LICENSE +0 -19
  50. package/vendor/brotli/MANIFEST.in +0 -17
  51. package/vendor/brotli/Makefile +0 -55
  52. package/vendor/brotli/Makefile.am +0 -38
  53. package/vendor/brotli/README +0 -15
  54. package/vendor/brotli/README.md +0 -104
  55. package/vendor/brotli/WORKSPACE +0 -21
  56. package/vendor/brotli/bootstrap +0 -35
  57. package/vendor/brotli/c/common/constants.c +0 -15
  58. package/vendor/brotli/c/common/constants.h +0 -200
  59. package/vendor/brotli/c/common/context.c +0 -156
  60. package/vendor/brotli/c/common/context.h +0 -113
  61. package/vendor/brotli/c/common/dictionary.c +0 -5914
  62. package/vendor/brotli/c/common/dictionary.h +0 -64
  63. package/vendor/brotli/c/common/platform.c +0 -22
  64. package/vendor/brotli/c/common/platform.h +0 -596
  65. package/vendor/brotli/c/common/transform.c +0 -291
  66. package/vendor/brotli/c/common/transform.h +0 -85
  67. package/vendor/brotli/c/common/version.h +0 -26
  68. package/vendor/brotli/c/dec/bit_reader.c +0 -76
  69. package/vendor/brotli/c/dec/bit_reader.h +0 -351
  70. package/vendor/brotli/c/dec/decode.c +0 -2608
  71. package/vendor/brotli/c/dec/huffman.c +0 -339
  72. package/vendor/brotli/c/dec/huffman.h +0 -121
  73. package/vendor/brotli/c/dec/prefix.h +0 -732
  74. package/vendor/brotli/c/dec/state.c +0 -159
  75. package/vendor/brotli/c/dec/state.h +0 -365
  76. package/vendor/brotli/c/enc/backward_references.c +0 -145
  77. package/vendor/brotli/c/enc/backward_references.h +0 -39
  78. package/vendor/brotli/c/enc/backward_references_hq.c +0 -843
  79. package/vendor/brotli/c/enc/backward_references_hq.h +0 -95
  80. package/vendor/brotli/c/enc/backward_references_inc.h +0 -163
  81. package/vendor/brotli/c/enc/bit_cost.c +0 -35
  82. package/vendor/brotli/c/enc/bit_cost.h +0 -63
  83. package/vendor/brotli/c/enc/bit_cost_inc.h +0 -127
  84. package/vendor/brotli/c/enc/block_encoder_inc.h +0 -34
  85. package/vendor/brotli/c/enc/block_splitter.c +0 -194
  86. package/vendor/brotli/c/enc/block_splitter.h +0 -51
  87. package/vendor/brotli/c/enc/block_splitter_inc.h +0 -440
  88. package/vendor/brotli/c/enc/brotli_bit_stream.c +0 -1314
  89. package/vendor/brotli/c/enc/brotli_bit_stream.h +0 -84
  90. package/vendor/brotli/c/enc/cluster.c +0 -56
  91. package/vendor/brotli/c/enc/cluster.h +0 -48
  92. package/vendor/brotli/c/enc/cluster_inc.h +0 -320
  93. package/vendor/brotli/c/enc/command.c +0 -28
  94. package/vendor/brotli/c/enc/command.h +0 -190
  95. package/vendor/brotli/c/enc/compress_fragment.c +0 -790
  96. package/vendor/brotli/c/enc/compress_fragment.h +0 -61
  97. package/vendor/brotli/c/enc/compress_fragment_two_pass.c +0 -645
  98. package/vendor/brotli/c/enc/compress_fragment_two_pass.h +0 -54
  99. package/vendor/brotli/c/enc/dictionary_hash.c +0 -1846
  100. package/vendor/brotli/c/enc/dictionary_hash.h +0 -25
  101. package/vendor/brotli/c/enc/encode.c +0 -1927
  102. package/vendor/brotli/c/enc/encoder_dict.c +0 -33
  103. package/vendor/brotli/c/enc/encoder_dict.h +0 -43
  104. package/vendor/brotli/c/enc/entropy_encode.c +0 -503
  105. package/vendor/brotli/c/enc/entropy_encode.h +0 -122
  106. package/vendor/brotli/c/enc/entropy_encode_static.h +0 -539
  107. package/vendor/brotli/c/enc/fast_log.c +0 -105
  108. package/vendor/brotli/c/enc/fast_log.h +0 -66
  109. package/vendor/brotli/c/enc/find_match_length.h +0 -79
  110. package/vendor/brotli/c/enc/hash.h +0 -488
  111. package/vendor/brotli/c/enc/hash_composite_inc.h +0 -125
  112. package/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +0 -293
  113. package/vendor/brotli/c/enc/hash_longest_match64_inc.h +0 -267
  114. package/vendor/brotli/c/enc/hash_longest_match_inc.h +0 -262
  115. package/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +0 -266
  116. package/vendor/brotli/c/enc/hash_rolling_inc.h +0 -212
  117. package/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +0 -329
  118. package/vendor/brotli/c/enc/histogram.c +0 -100
  119. package/vendor/brotli/c/enc/histogram.h +0 -63
  120. package/vendor/brotli/c/enc/histogram_inc.h +0 -51
  121. package/vendor/brotli/c/enc/literal_cost.c +0 -175
  122. package/vendor/brotli/c/enc/literal_cost.h +0 -30
  123. package/vendor/brotli/c/enc/memory.c +0 -170
  124. package/vendor/brotli/c/enc/memory.h +0 -114
  125. package/vendor/brotli/c/enc/metablock.c +0 -663
  126. package/vendor/brotli/c/enc/metablock.h +0 -105
  127. package/vendor/brotli/c/enc/metablock_inc.h +0 -183
  128. package/vendor/brotli/c/enc/params.h +0 -46
  129. package/vendor/brotli/c/enc/prefix.h +0 -53
  130. package/vendor/brotli/c/enc/quality.h +0 -165
  131. package/vendor/brotli/c/enc/ringbuffer.h +0 -167
  132. package/vendor/brotli/c/enc/static_dict.c +0 -486
  133. package/vendor/brotli/c/enc/static_dict.h +0 -40
  134. package/vendor/brotli/c/enc/static_dict_lut.h +0 -5864
  135. package/vendor/brotli/c/enc/utf8_util.c +0 -85
  136. package/vendor/brotli/c/enc/utf8_util.h +0 -32
  137. package/vendor/brotli/c/enc/write_bits.h +0 -87
  138. package/vendor/brotli/c/include/brotli/decode.h +0 -344
  139. package/vendor/brotli/c/include/brotli/encode.h +0 -448
  140. package/vendor/brotli/c/include/brotli/port.h +0 -288
  141. package/vendor/brotli/c/include/brotli/types.h +0 -83
  142. package/vendor/brotli/c/tools/brotli.c +0 -1116
  143. package/vendor/brotli/c/tools/brotli.md +0 -107
  144. package/vendor/brotli/compiler_config_setting.bzl +0 -28
  145. package/vendor/brotli/configure +0 -8
  146. package/vendor/brotli/configure-cmake +0 -318
  147. package/vendor/brotli/configure.ac +0 -14
  148. package/vendor/brotli/docs/brotli.1 +0 -132
  149. package/vendor/brotli/docs/constants.h.3 +0 -47
  150. package/vendor/brotli/docs/decode.h.3 +0 -415
  151. package/vendor/brotli/docs/encode.h.3 +0 -586
  152. package/vendor/brotli/docs/types.h.3 +0 -117
  153. package/vendor/brotli/premake5.lua +0 -78
  154. package/vendor/brotli/python/Makefile +0 -57
  155. package/vendor/brotli/python/README.md +0 -54
  156. package/vendor/brotli/python/_brotli.cc +0 -753
  157. package/vendor/brotli/python/bro.py +0 -160
  158. package/vendor/brotli/python/brotli.py +0 -56
  159. package/vendor/brotli/python/tests/__init__.py +0 -0
  160. package/vendor/brotli/python/tests/_test_utils.py +0 -112
  161. package/vendor/brotli/python/tests/bro_test.py +0 -102
  162. package/vendor/brotli/python/tests/compress_test.py +0 -41
  163. package/vendor/brotli/python/tests/compressor_test.py +0 -94
  164. package/vendor/brotli/python/tests/decompress_test.py +0 -42
  165. package/vendor/brotli/python/tests/decompressor_test.py +0 -59
  166. package/vendor/brotli/scripts/libbrotlicommon.pc.in +0 -11
  167. package/vendor/brotli/scripts/libbrotlidec.pc.in +0 -12
  168. package/vendor/brotli/scripts/libbrotlienc.pc.in +0 -12
  169. package/vendor/brotli/scripts/sources.lst +0 -104
  170. package/vendor/brotli/setup.cfg +0 -5
  171. package/vendor/brotli/setup.py +0 -293
  172. package/vendor/brotli/tests/Makefile +0 -17
  173. package/vendor/brotli/tests/compatibility_test.sh +0 -25
  174. package/vendor/brotli/tests/roundtrip_test.sh +0 -36
  175. package/vendor/brotli/tests/run-compatibility-test.cmake +0 -31
  176. package/vendor/brotli/tests/run-roundtrip-test.cmake +0 -36
  177. package/vendor/brotli/tests/testdata/empty +0 -0
  178. package/vendor/brotli/tests/testdata/empty.compressed +0 -1
  179. package/vendor/brotli/tests/testdata/ukkonooa +0 -1
  180. package/vendor/brotli/tests/testdata/ukkonooa.compressed +0 -0
  181. package/vendor/dragonbox/CMakeLists.txt +0 -123
  182. package/vendor/dragonbox/LICENSE-Apache2-LLVM +0 -218
  183. package/vendor/dragonbox/LICENSE-Boost +0 -23
  184. package/vendor/dragonbox/README.md +0 -277
  185. package/vendor/dragonbox/cmake/dragonboxConfig.cmake +0 -1
  186. package/vendor/dragonbox/include/dragonbox/dragonbox.h +0 -2674
  187. package/vendor/dragonbox/include/dragonbox/dragonbox_to_chars.h +0 -108
  188. package/vendor/dragonbox/other_files/Dragonbox.pdf +0 -0
  189. package/vendor/dragonbox/other_files/Dragonbox_old.pdf +0 -0
  190. package/vendor/dragonbox/other_files/milo_benchmark.png +0 -0
  191. package/vendor/dragonbox/other_files/unknown_win64_vc2019.html +0 -540
  192. package/vendor/dragonbox/other_files/unknown_win64_vc2019_randomdigit_time.png +0 -0
  193. package/vendor/dragonbox/source/dragonbox_to_chars.cpp +0 -303
  194. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/CMakeLists.txt +0 -24
  195. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.cpp +0 -238
  196. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/fp_to_chars.h +0 -95
  197. package/vendor/dragonbox/subproject/3rdparty/grisu_exact/grisu_exact.h +0 -2666
  198. package/vendor/dragonbox/subproject/3rdparty/ryu/CMakeLists.txt +0 -16
  199. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/common.h +0 -114
  200. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s.c +0 -509
  201. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_full_table.h +0 -367
  202. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/d2s_intrinsics.h +0 -357
  203. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/digit_table.h +0 -35
  204. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s.c +0 -345
  205. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_full_table.h +0 -55
  206. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/f2s_intrinsics.h +0 -128
  207. package/vendor/dragonbox/subproject/3rdparty/ryu/ryu/ryu.h +0 -46
  208. package/vendor/dragonbox/subproject/3rdparty/schubfach/CMakeLists.txt +0 -22
  209. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.cc +0 -699
  210. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_32.h +0 -31
  211. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.cc +0 -1354
  212. package/vendor/dragonbox/subproject/3rdparty/schubfach/schubfach_64.h +0 -31
  213. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/example_shaded_plots.m +0 -68
  214. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/license.txt +0 -25
  215. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution.m +0 -92
  216. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_distribution_prctile.m +0 -121
  217. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_histogram_shaded.m +0 -99
  218. package/vendor/dragonbox/subproject/3rdparty/shaded_plots/plot_shaded.m +0 -93
  219. package/vendor/dragonbox/subproject/benchmark/CMakeLists.txt +0 -65
  220. package/vendor/dragonbox/subproject/benchmark/include/benchmark.h +0 -40
  221. package/vendor/dragonbox/subproject/benchmark/matlab/plot_benchmarks.m +0 -22
  222. package/vendor/dragonbox/subproject/benchmark/matlab/plot_digit_benchmark.m +0 -78
  223. package/vendor/dragonbox/subproject/benchmark/matlab/plot_uniform_benchmark.m +0 -95
  224. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_clang.png +0 -0
  225. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary32_msvc.png +0 -0
  226. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_clang.png +0 -0
  227. package/vendor/dragonbox/subproject/benchmark/results/digits_benchmark_binary64_msvc.png +0 -0
  228. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_clang.png +0 -0
  229. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary32_msvc.png +0 -0
  230. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_clang.png +0 -0
  231. package/vendor/dragonbox/subproject/benchmark/results/uniform_benchmark_binary64_msvc.png +0 -0
  232. package/vendor/dragonbox/subproject/benchmark/source/benchmark.cpp +0 -238
  233. package/vendor/dragonbox/subproject/benchmark/source/dragonbox.cpp +0 -30
  234. package/vendor/dragonbox/subproject/benchmark/source/grisu_exact.cpp +0 -36
  235. package/vendor/dragonbox/subproject/benchmark/source/ryu.cpp +0 -27
  236. package/vendor/dragonbox/subproject/benchmark/source/schubfach.cpp +0 -31
  237. package/vendor/dragonbox/subproject/common/CMakeLists.txt +0 -42
  238. package/vendor/dragonbox/subproject/common/include/best_rational_approx.h +0 -97
  239. package/vendor/dragonbox/subproject/common/include/big_uint.h +0 -218
  240. package/vendor/dragonbox/subproject/common/include/continued_fractions.h +0 -174
  241. package/vendor/dragonbox/subproject/common/include/good_rational_approx.h +0 -267
  242. package/vendor/dragonbox/subproject/common/include/random_float.h +0 -182
  243. package/vendor/dragonbox/subproject/common/include/rational_continued_fractions.h +0 -57
  244. package/vendor/dragonbox/subproject/common/source/big_uint.cpp +0 -602
  245. package/vendor/dragonbox/subproject/meta/CMakeLists.txt +0 -41
  246. package/vendor/dragonbox/subproject/meta/results/binary32_generated_cache.txt +0 -82
  247. package/vendor/dragonbox/subproject/meta/results/binary64_compressed_cache_error_table.txt +0 -10
  248. package/vendor/dragonbox/subproject/meta/results/binary64_generated_cache.txt +0 -623
  249. package/vendor/dragonbox/subproject/meta/source/generate_cache.cpp +0 -126
  250. package/vendor/dragonbox/subproject/meta/source/live_test.cpp +0 -81
  251. package/vendor/dragonbox/subproject/meta/source/perf_test.cpp +0 -104
  252. package/vendor/dragonbox/subproject/meta/source/sandbox.cpp +0 -20
  253. package/vendor/dragonbox/subproject/test/CMakeLists.txt +0 -70
  254. package/vendor/dragonbox/subproject/test/results/binary32.csv +0 -255
  255. package/vendor/dragonbox/subproject/test/results/binary64.csv +0 -2047
  256. package/vendor/dragonbox/subproject/test/results/plot_required_bits.m +0 -18
  257. package/vendor/dragonbox/subproject/test/source/test_all_shorter_interval_cases.cpp +0 -88
  258. package/vendor/dragonbox/subproject/test/source/uniform_random_test.cpp +0 -95
  259. package/vendor/dragonbox/subproject/test/source/verify_cache_precision.cpp +0 -338
  260. package/vendor/dragonbox/subproject/test/source/verify_compressed_cache.cpp +0 -154
  261. package/vendor/dragonbox/subproject/test/source/verify_fast_multiplication.cpp +0 -168
  262. package/vendor/dragonbox/subproject/test/source/verify_log_computation.cpp +0 -251
  263. package/vendor/dragonbox/subproject/test/source/verify_magic_division.cpp +0 -113
  264. package/vendor/miniz/ChangeLog.md +0 -239
  265. package/vendor/miniz/LICENSE +0 -22
  266. package/vendor/miniz/examples/example1.c +0 -105
  267. package/vendor/miniz/examples/example2.c +0 -164
  268. package/vendor/miniz/examples/example3.c +0 -269
  269. package/vendor/miniz/examples/example4.c +0 -102
  270. package/vendor/miniz/examples/example5.c +0 -327
  271. package/vendor/miniz/examples/example6.c +0 -166
  272. package/vendor/miniz/miniz.c +0 -7835
  273. package/vendor/miniz/miniz.h +0 -1422
  274. package/vendor/miniz/readme.md +0 -46
  275. /package/src/koffi/build/{2.3.6 → 2.3.8}/koffi_win32_arm64/koffi.exp +0 -0
  276. /package/src/koffi/build/{2.3.6 → 2.3.8}/koffi_win32_arm64/koffi.lib +0 -0
  277. /package/src/koffi/build/{2.3.6 → 2.3.8}/koffi_win32_ia32/koffi.exp +0 -0
  278. /package/src/koffi/build/{2.3.6 → 2.3.8}/koffi_win32_ia32/koffi.lib +0 -0
  279. /package/src/koffi/build/{2.3.6 → 2.3.8}/koffi_win32_x64/koffi.exp +0 -0
  280. /package/src/koffi/build/{2.3.6 → 2.3.8}/koffi_win32_x64/koffi.lib +0 -0
@@ -1,154 +0,0 @@
1
- // Copyright 2020-2022 Junekey Jeon
2
- //
3
- // The contents of this file may be used under the terms of
4
- // the Apache License v2.0 with LLVM Exceptions.
5
- //
6
- // (See accompanying file LICENSE-Apache or copy at
7
- // https://llvm.org/foundation/relicensing/LICENSE.txt)
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
- #include "dragonbox/dragonbox.h"
19
- #include "big_uint.h"
20
- #include "rational_continued_fractions.h"
21
-
22
- #include <fstream>
23
- #include <iomanip>
24
- #include <iostream>
25
- #include <vector>
26
-
27
- int main() {
28
- // We are trying to verify that an appropriate shift of phi_k * 5^a
29
- // can be used instead of phi_(a+k). Since phi_k is defined in terms of ceiling,
30
- // the shift of phi_k * 5^a will be phi_(a+k) + (error) for some nonnegative error.
31
- //
32
- // For correct multiplication, the margin for binary32 is at least
33
- // 2^64 * 5091154818982829 / 12349290596248284087255008291061760 = 7.60...,
34
- // so we are safe if the error is up to 7.
35
- // The margin for binary64 is at least
36
- // 2^128 * 723173431431821867556830303887 /
37
- // 18550103527668669801949286474444582643081334006759269899933694558208
38
- // = 13.26..., so we are safe if the error is up to 13.
39
- //
40
- // For correct integer checks, the case b > n_max is fine because the only condition on the
41
- // recovered cache is a lower bound which must be already true for phi_k.
42
- // For the case b <= n_max, we only need to check the upper bound
43
- // (recovered_cache) < 2^(Q-beta) * a/b + 2^(q-beta)/(floor(nmax/b) * b),
44
- // so we check it manually for each e.
45
-
46
- using namespace jkj::dragonbox::detail::log;
47
- using namespace jkj::dragonbox::detail::wuint;
48
- using info = jkj::dragonbox::detail::compressed_cache_detail;
49
- using impl = jkj::dragonbox::detail::impl<double>;
50
-
51
- std::cout << "[Verifying cache recovery for compressed cache...]\n";
52
-
53
- jkj::unsigned_rational<jkj::big_uint> unit;
54
- auto n_max = jkj::big_uint::power_of_2(impl::significand_bits + 2);
55
- int prev_k = impl::max_k + 1;
56
- for (int e = impl::min_exponent - impl::significand_bits;
57
- e <= impl::max_exponent - impl::significand_bits; ++e) {
58
- int const k = impl::kappa - floor_log10_pow2(e);
59
-
60
- using jkj::dragonbox::policy::cache::full;
61
- auto const real_cache = full.get_cache<jkj::dragonbox::ieee754_binary64>(k);
62
-
63
- // Compute the base index.
64
- int const kb =
65
- ((k - impl::min_k) / info::compression_ratio) * info::compression_ratio + impl::min_k;
66
-
67
- // Get the base cache.
68
- auto const base_cache = full.get_cache<jkj::dragonbox::ieee754_binary64>(kb);
69
-
70
- // Get the index offset.
71
- auto const offset = k - kb;
72
-
73
- if (offset != 0) {
74
- // Obtain the corresponding power of 5.
75
- auto const pow5 = info::pow5.table[offset];
76
-
77
- // Compute the required amount of bit-shifts.
78
- auto const alpha = floor_log2_pow10(kb + offset) - floor_log2_pow10(kb) - offset;
79
- assert(alpha > 0 && alpha < 64);
80
-
81
- // Try to recover the real cache.
82
- auto recovered_cache = umul128(base_cache.high(), pow5);
83
- auto const middle_low = umul128(base_cache.low(), pow5);
84
-
85
- recovered_cache += middle_low.high();
86
-
87
- auto const high_to_middle = recovered_cache.high() << (64 - alpha);
88
- auto const middle_to_low = recovered_cache.low() << (64 - alpha);
89
-
90
- recovered_cache = uint128{(recovered_cache.low() >> alpha) | high_to_middle,
91
- ((middle_low.low() >> alpha) | middle_to_low)};
92
-
93
- if (recovered_cache.low() + 1 == 0) {
94
- std::cout << "Overflow detected.\n";
95
- return -1;
96
- }
97
- else {
98
- recovered_cache = {recovered_cache.high(), recovered_cache.low() + 1};
99
- }
100
-
101
- // Measure the difference
102
- if (real_cache.high() != recovered_cache.high() ||
103
- real_cache.low() > recovered_cache.low()) {
104
- std::cout << "Overflow detected.\n";
105
- return -1;
106
- }
107
- auto const diff = std::uint32_t(recovered_cache.low() - real_cache.low());
108
-
109
- if (diff != 0) {
110
- if (diff > 13) {
111
- // Multiplication might be no longer valid.
112
- std::cout << "Overflow detected.\n";
113
- return -1;
114
- }
115
-
116
- // For the case b <= n_max, integer check might be no longer valid.
117
- int const beta = e + floor_log2_pow10(k);
118
-
119
- // unit = 2^(e + k - 1) * 5^k = a/b.
120
- unit.numerator = 1;
121
- unit.denominator = 1;
122
- if (k >= 0) {
123
- unit.numerator = jkj::big_uint::pow(5, k);
124
- }
125
- else {
126
- unit.denominator = jkj::big_uint::pow(5, -k);
127
- }
128
- if (e + k - 1 >= 0) {
129
- unit.numerator *= jkj::big_uint::power_of_2(e + k - 1);
130
- }
131
- else {
132
- unit.denominator *= jkj::big_uint::power_of_2(-e - k + 1);
133
- }
134
-
135
- if (unit.denominator <= n_max) {
136
- // Check (recovered_cache) < 2^(Q-beta) * a/b + 2^(q-beta)/(floor(nmax/b) * b),
137
- // or equivalently,
138
- // b * (recovered_cache) - 2^(Q-beta) * a < 2^(q-beta) / floor(nmax/b).
139
- auto const rc = jkj::big_uint{recovered_cache.low(), recovered_cache.high()};
140
- auto const left_hand_side =
141
- unit.denominator * rc -
142
- jkj::big_uint::power_of_2(impl::cache_bits - beta) * unit.numerator;
143
-
144
- if (left_hand_side * (n_max / unit.denominator) >=
145
- jkj::big_uint::power_of_2(impl::carrier_bits - beta)) {
146
- std::cout << "Overflow detected.\n";
147
- return -1;
148
- }
149
- }
150
- }
151
- }
152
- }
153
- std::cout << "Verification succeeded. No error detected.\n";
154
- }
@@ -1,168 +0,0 @@
1
- // Copyright 2020-2022 Junekey Jeon
2
- //
3
- // The contents of this file may be used under the terms of
4
- // the Apache License v2.0 with LLVM Exceptions.
5
- //
6
- // (See accompanying file LICENSE-Apache or copy at
7
- // https://llvm.org/foundation/relicensing/LICENSE.txt)
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
- #include "dragonbox/dragonbox.h"
19
- #include "big_uint.h"
20
- #include "continued_fractions.h"
21
-
22
- #include <iostream>
23
-
24
- template <class Float, class CachePolicy>
25
- static bool verify_fast_multiplication_xz(CachePolicy&& cache_policy) {
26
- using impl = jkj::dragonbox::detail::impl<Float>;
27
- using format = typename impl::format;
28
- using carrier_uint = typename impl::carrier_uint;
29
-
30
- constexpr auto four_fl = (carrier_uint(1) << (impl::significand_bits + 2)) - 1;
31
- constexpr auto two_fr = (carrier_uint(1) << (impl::significand_bits + 1)) + 1;
32
-
33
- using jkj::dragonbox::detail::log::floor_log10_pow2_minus_log10_4_over_3;
34
- using jkj::dragonbox::detail::log::floor_log2_pow10;
35
-
36
- bool success = true;
37
-
38
- for (int e = impl::min_exponent + 1 - impl::significand_bits;
39
- e <= impl::max_exponent - impl::significand_bits; ++e) {
40
-
41
- // Compute k and beta.
42
- int const k = -floor_log10_pow2_minus_log10_4_over_3(e);
43
- int const beta = e + floor_log2_pow10(k);
44
-
45
- // Load cache.
46
- auto const cache = cache_policy.template get_cache<format>(k);
47
-
48
- // Compute the endpoints using the fast method.
49
- auto x_fast = impl::compute_left_endpoint_for_shorter_interval_case(cache, beta);
50
- auto z_fast = impl::compute_right_endpoint_for_shorter_interval_case(cache, beta);
51
-
52
- // Precisely compute the endpoints.
53
- jkj::unsigned_rational<jkj::big_uint> precise_multiplier{1, 1};
54
- if (k >= 0) {
55
- precise_multiplier.numerator = jkj::big_uint::pow(5, k);
56
- }
57
- else {
58
- precise_multiplier.denominator = jkj::big_uint::pow(5, -k);
59
- }
60
- if (e + k >= 0) {
61
- precise_multiplier.numerator *= jkj::big_uint::power_of_2(e + k);
62
- }
63
- else {
64
- precise_multiplier.denominator *= jkj::big_uint::power_of_2(-e - k);
65
- }
66
-
67
- auto x_exact =
68
- (four_fl * precise_multiplier.numerator) / (4 * precise_multiplier.denominator);
69
- auto z_exact =
70
- (two_fr * precise_multiplier.numerator) / (2 * precise_multiplier.denominator);
71
-
72
- if (x_exact != x_fast) {
73
- std::cout << "(e = " << e << ") left endpoint is not correct; computed = " << x_fast
74
- << "; true_value = " << x_exact[0] << "\n";
75
- success = false;
76
- }
77
- if (z_exact != z_fast) {
78
- std::cout << "(e = " << e << ") right endpoint is not correct; computed = " << z_fast
79
- << "; true_value = " << z_exact[0] << "\n";
80
- success = false;
81
- }
82
- }
83
-
84
- if (success) {
85
- std::cout << "All cases are verified.\n";
86
- }
87
- else {
88
- std::cout << "Error detected.\n";
89
- }
90
-
91
- return success;
92
- }
93
-
94
- template <class Float, class CachePolicy>
95
- static bool verify_fast_multiplication_yru(CachePolicy&& cache_policy) {
96
- using impl = jkj::dragonbox::detail::impl<Float>;
97
- using format = typename impl::format;
98
- bool success = true;
99
-
100
- for (int k = impl::min_k; k <= impl::max_k; ++k) {
101
- auto const cache = cache_policy.template get_cache<format>(k);
102
-
103
- // Since Q - p - beta - 2 >= q, it suffices to check that the lower half of the cache is not 0.
104
- auto const lower_half = [cache] {
105
- if constexpr (std::is_same_v<typename impl::format, jkj::dragonbox::ieee754_binary32>) {
106
- return std::uint32_t(cache);
107
- }
108
- else {
109
- return cache.low();
110
- }
111
- }();
112
-
113
- // If the lower half is zero, we need to check if the cache is precise.
114
- if (lower_half == 0) {
115
- if (k < 0 || k > jkj::dragonbox::detail::log::floor_log5_pow2(impl::cache_bits)) {
116
- std::cout << "(k = " << k << ") computation might be incorrect\n";
117
- success = false;
118
- }
119
- }
120
- }
121
-
122
- if (success) {
123
- std::cout << "All cases are verified.\n";
124
- }
125
- else {
126
- std::cout << "Error detected.\n";
127
- }
128
-
129
- return success;
130
- }
131
-
132
- int main() {
133
- bool success = true;
134
-
135
- std::cout << "[Verifying fast computation of xi and zi for the shorter interval case "
136
- "with full cache (binary32)...]\n";
137
- success &= verify_fast_multiplication_xz<float>(jkj::dragonbox::policy::cache::full);
138
- std::cout << "Done.\n\n\n";
139
-
140
- std::cout << "[Verifying fast computation of yru for the shorter interval case "
141
- "with full cache (binary32)...]\n";
142
- success &= verify_fast_multiplication_yru<float>(jkj::dragonbox::policy::cache::full);
143
- std::cout << "Done.\n\n\n";
144
-
145
- std::cout << "[Verifying fast computation of xi and zi for the shorter interval case "
146
- "with full cache (binary64)...]\n";
147
- success &= verify_fast_multiplication_xz<double>(jkj::dragonbox::policy::cache::full);
148
- std::cout << "Done.\n\n\n";
149
-
150
- std::cout << "[Verifying fast computation of xi and zi for the shorter interval case "
151
- "with compressed cache (binary64)...]\n";
152
- success &= verify_fast_multiplication_xz<double>(jkj::dragonbox::policy::cache::compact);
153
- std::cout << "Done.\n\n\n";
154
-
155
- std::cout << "[Verifying fast computation of yru for the shorter interval case "
156
- "with full cache (binary64)...]\n";
157
- success &= verify_fast_multiplication_yru<double>(jkj::dragonbox::policy::cache::full);
158
- std::cout << "Done.\n\n\n";
159
-
160
- std::cout << "[Verifying fast computation of yru for the shorter interval case "
161
- "with compressed cache (binary64)...]\n";
162
- success &= verify_fast_multiplication_yru<double>(jkj::dragonbox::policy::cache::compact);
163
- std::cout << "Done.\n\n\n";
164
-
165
- if (!success) {
166
- return -1;
167
- }
168
- }
@@ -1,251 +0,0 @@
1
- // Copyright 2020 Junekey Jeon
2
- //
3
- // The contents of this file may be used under the terms of
4
- // the Apache License v2.0 with LLVM Exceptions.
5
- //
6
- // (See accompanying file LICENSE-Apache or copy at
7
- // https://llvm.org/foundation/relicensing/LICENSE.txt)
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
- #include "big_uint.h"
19
- #include "dragonbox/dragonbox.h"
20
-
21
- #include <functional>
22
- #include <iostream>
23
-
24
- int floor_log10_pow2_precise(int e) {
25
- using namespace jkj::dragonbox::detail::log;
26
- bool is_negative;
27
- if (e < 0) {
28
- is_negative = true;
29
- e = -e;
30
- }
31
- else {
32
- is_negative = false;
33
- }
34
-
35
- auto power_of_2 = jkj::big_uint::power_of_2(std::size_t(e));
36
- auto power_of_10 = jkj::big_uint(1);
37
- int k = 0;
38
- while (power_of_10 <= power_of_2) {
39
- power_of_10.multiply_5();
40
- power_of_10.multiply_2();
41
- ++k;
42
- }
43
-
44
- return is_negative ? -k : k - 1;
45
- }
46
-
47
- int floor_log10_pow2_minus_log10_4_over_3_precise(int e) {
48
- e -= 2;
49
-
50
- if (e < 0) {
51
- e = -e;
52
- auto power_of_2 = jkj::big_uint::power_of_2(std::size_t(e));
53
- auto power_of_10_times_3 = jkj::big_uint(3);
54
- int k = 0;
55
- while (power_of_10_times_3 < power_of_2) {
56
- power_of_10_times_3.multiply_5();
57
- power_of_10_times_3.multiply_2();
58
- ++k;
59
- }
60
- return -k;
61
- }
62
- else {
63
- auto power_of_2_times_3 = jkj::big_uint::power_of_2(std::size_t(e)) * 3;
64
- auto power_of_10 = jkj::big_uint(1);
65
- int k = 0;
66
- while (power_of_10 <= power_of_2_times_3) {
67
- power_of_10.multiply_5();
68
- power_of_10.multiply_2();
69
- ++k;
70
- }
71
- return k - 1;
72
- }
73
- }
74
-
75
- int floor_log2_pow10_precise(int e) {
76
- bool is_negative;
77
- if (e < 0) {
78
- is_negative = true;
79
- e = -e;
80
- }
81
- else {
82
- is_negative = false;
83
- }
84
-
85
- auto power_of_10 = jkj::big_uint(1);
86
- for (int i = 0; i < e; ++i) {
87
- power_of_10.multiply_5();
88
- power_of_10.multiply_2();
89
- }
90
-
91
- auto k = int(log2p1(power_of_10));
92
-
93
- return is_negative ? -k : k - 1;
94
- }
95
-
96
- int floor_log5_pow2_precise(int e) {
97
- bool is_negative;
98
- if (e < 0) {
99
- is_negative = true;
100
- e = -e;
101
- }
102
- else {
103
- is_negative = false;
104
- }
105
-
106
- auto power_of_2 = jkj::big_uint::power_of_2(std::size_t(e));
107
- auto power_of_5 = jkj::big_uint(1);
108
- int k = 0;
109
- while (power_of_5 <= power_of_2) {
110
- power_of_5.multiply_5();
111
- ++k;
112
- }
113
-
114
- return is_negative ? -k : k - 1;
115
- }
116
-
117
- int floor_log5_pow2_minus_log5_3_precise(int e) {
118
- if (e >= 0) {
119
- auto power_of_2 = jkj::big_uint::power_of_2(std::size_t(e));
120
- auto power_of_5_times_3 = jkj::big_uint(3);
121
- int k = 0;
122
- while (power_of_5_times_3 <= power_of_2) {
123
- power_of_5_times_3.multiply_5();
124
- ++k;
125
- }
126
- return k - 1;
127
- }
128
- else {
129
- e = -e;
130
- auto power_of_2_times_3 = jkj::big_uint::power_of_2(std::size_t(e)) * 3;
131
- auto power_of_5 = jkj::big_uint(1);
132
- int k = 0;
133
- while (power_of_5 < power_of_2_times_3) {
134
- power_of_5.multiply_5();
135
- ++k;
136
- }
137
- return -k;
138
- }
139
- }
140
-
141
- struct verify_result {
142
- int min_exponent;
143
- int max_exponent;
144
- };
145
-
146
- template <jkj::dragonbox::detail::log::multiply m, jkj::dragonbox::detail::log::subtract f,
147
- jkj::dragonbox::detail::log::shift k>
148
- verify_result verify(std::string_view name, std::function<int(int)> precise_calculator = nullptr) {
149
- // Compute the maximum possible e
150
- constexpr auto max_exponent_upper_bound =
151
- std::numeric_limits<std::int32_t>::max() / std::int32_t(m);
152
- constexpr auto min_exponent_lower_bound =
153
- -std::int32_t(-std::int64_t(std::numeric_limits<std::int32_t>::min() + std::int32_t(f)) /
154
- std::int32_t(m));
155
-
156
- verify_result result{int(min_exponent_lower_bound), int(max_exponent_upper_bound)};
157
-
158
- bool reach_upper_bound = false;
159
- bool reach_lower_bound = false;
160
- for (std::int32_t e = 0; e <= std::max(-min_exponent_lower_bound, max_exponent_upper_bound);
161
- ++e) {
162
- if (!reach_upper_bound) {
163
- auto true_value = precise_calculator(int(e));
164
- auto computed_value = int((e * std::int32_t(m) - std::int32_t(f)) >> std::size_t(k));
165
- if (computed_value != true_value) {
166
- std::cout << " - error with positive e ("
167
- << "e: " << e << ", true value: " << true_value
168
- << ", computed value: " << computed_value << ")\n";
169
-
170
- reach_upper_bound = true;
171
- result.max_exponent = int(e) - 1;
172
- }
173
- }
174
-
175
- if (!reach_lower_bound) {
176
- auto true_value = precise_calculator(-int(e));
177
- auto computed_value = int((-e * std::int32_t(m) - std::int32_t(f)) >> std::size_t(k));
178
- if (computed_value != true_value) {
179
- std::cout << " - error with negative e ("
180
- << "e: " << (-int(e)) << ", true value: " << true_value
181
- << ", computed value: " << computed_value << ")\n";
182
-
183
- reach_lower_bound = true;
184
- result.min_exponent = -int(e) + 1;
185
- }
186
- }
187
-
188
- if (reach_upper_bound && reach_lower_bound) {
189
- break;
190
- }
191
- }
192
-
193
- std::cout << name << " is correct for e in [" << result.min_exponent << ", "
194
- << result.max_exponent << "]\n\n";
195
-
196
- return result;
197
- }
198
-
199
- int main() {
200
- using namespace jkj::dragonbox::detail::log;
201
-
202
- bool success = true;
203
- std::cout << "[Verifying log computation...]\n";
204
-
205
- {
206
- auto result = verify<multiply(315653), subtract(0), shift(20)>("floor_log10_pow2",
207
- floor_log10_pow2_precise);
208
- if (result.min_exponent > floor_log10_pow2_min_exponent ||
209
- result.max_exponent < floor_log10_pow2_max_exponent) {
210
- success = false;
211
- }
212
- }
213
- {
214
- auto result = verify<multiply(1741647), subtract(0), shift(19)>("floor_log2_pow10",
215
- floor_log2_pow10_precise);
216
- if (result.min_exponent > floor_log2_pow10_min_exponent ||
217
- result.max_exponent < floor_log2_pow10_max_exponent) {
218
- success = false;
219
- }
220
- }
221
- {
222
- auto result = verify<multiply(631305), subtract(261663), shift(21)>(
223
- "floor_log10_pow2_minus_log10_4_over_3", floor_log10_pow2_minus_log10_4_over_3_precise);
224
- if (result.min_exponent > floor_log10_pow2_minus_log10_4_over_3_min_exponent ||
225
- result.max_exponent < floor_log10_pow2_minus_log10_4_over_3_max_exponent) {
226
- success = false;
227
- }
228
- }
229
- {
230
- auto result = verify<multiply(225799), subtract(0), shift(19)>("floor_log5_pow2",
231
- floor_log5_pow2_precise);
232
- if (result.min_exponent > floor_log5_pow2_min_exponent ||
233
- result.max_exponent < floor_log5_pow2_max_exponent) {
234
- success = false;
235
- }
236
- }
237
- {
238
- auto result = verify<multiply(451597), subtract(715764), shift(20)>(
239
- "floor_log5_pow2_minus_log5_3", floor_log5_pow2_minus_log5_3_precise);
240
- if (result.min_exponent > floor_log5_pow2_minus_log5_3_min_exponent ||
241
- result.max_exponent < floor_log5_pow2_minus_log5_3_max_exponent) {
242
- success = false;
243
- }
244
- }
245
-
246
- std::cout << "Done.\n\n\n";
247
-
248
- if (!success) {
249
- return -1;
250
- }
251
- }
@@ -1,113 +0,0 @@
1
- // Copyright 2020 Junekey Jeon
2
- //
3
- // The contents of this file may be used under the terms of
4
- // the Apache License v2.0 with LLVM Exceptions.
5
- //
6
- // (See accompanying file LICENSE-Apache or copy at
7
- // https://llvm.org/foundation/relicensing/LICENSE.txt)
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
- #include "dragonbox/dragonbox.h"
19
-
20
- #include <iostream>
21
- #include <iomanip>
22
-
23
- template <class Float>
24
- static bool verify_check_divisibility_and_divide_by_pow10() {
25
- using namespace jkj::dragonbox::detail;
26
-
27
- constexpr int kappa = impl<Float>::kappa;
28
- constexpr auto max_n = compute_power<kappa + 1>(std::uint32_t(10));
29
- constexpr auto divisor = compute_power<kappa>(std::uint32_t(10));
30
-
31
- bool success = true;
32
- for (std::uint32_t n = 0; n <= max_n; ++n) {
33
- std::uint32_t computed_quotient = n;
34
- auto computed_divisibility =
35
- div::check_divisibility_and_divide_by_pow10<kappa>(computed_quotient);
36
-
37
- if (computed_quotient != (n / divisor)) {
38
- std::cout << "Dividing n = " << n << " by " << divisor
39
- << "; computed_quotient = " << computed_quotient
40
- << "; true_quotient = " << (n / divisor) << std::endl;
41
- success = false;
42
- }
43
- if (computed_divisibility != (n % divisor == 0)) {
44
- std::cout << "Dividing n = " << n << " by " << divisor
45
- << "; computed_divisibility = " << std::boolalpha << computed_divisibility
46
- << "; true_divisibility = " << (n % divisor == 0) << std::endl;
47
- success = false;
48
- }
49
- }
50
-
51
- if (success) {
52
- std::cout << "All cases are verified.\n";
53
- }
54
- else {
55
- std::cout << "Error detected.\n";
56
- }
57
-
58
- return success;
59
- }
60
-
61
- template <class Float>
62
- static bool verify_divide_by_pow10() {
63
- using namespace jkj::dragonbox::detail;
64
-
65
- constexpr int kappa = impl<Float>::kappa;
66
- constexpr auto max_n = compute_power<kappa + 1>(std::uint32_t(10));
67
- constexpr auto divisor = compute_power<kappa>(std::uint32_t(10));
68
-
69
- bool success = true;
70
- for (std::uint32_t n = 0; n <= max_n; ++n) {
71
- auto computed_quotient = div::small_division_by_pow10<kappa>(n);
72
-
73
- if (computed_quotient != (n / divisor)) {
74
- std::cout << "Dividing n = " << n << " by " << divisor
75
- << "; computed_quotient = " << computed_quotient
76
- << "; true_quotient = " << (n / divisor) << std::endl;
77
- success = false;
78
- }
79
- }
80
-
81
- if (success) {
82
- std::cout << "All cases are verified.\n";
83
- }
84
- else {
85
- std::cout << "Error detected.\n";
86
- }
87
-
88
- return success;
89
- }
90
-
91
- int main() {
92
- bool success = true;
93
-
94
- std::cout << "[Verifying divisibility check and division by 10^kappa for binary32...]\n";
95
- success &= verify_check_divisibility_and_divide_by_pow10<float>();
96
- std::cout << "Done.\n\n\n";
97
-
98
- std::cout << "[Verifying division by 10^kappa for binary32...]\n";
99
- success &= verify_divide_by_pow10<float>();
100
- std::cout << "Done.\n\n\n";
101
-
102
- std::cout << "[Verifying divisibility check and division by 10^kappa for binary64...]\n";
103
- success &= verify_check_divisibility_and_divide_by_pow10<double>();
104
- std::cout << "Done.\n\n\n";
105
-
106
- std::cout << "[Verifying division by 10^kappa for binary64...]\n";
107
- success &= verify_divide_by_pow10<double>();
108
- std::cout << "Done.\n\n\n";
109
-
110
- if (!success) {
111
- return -1;
112
- }
113
- }