dragonbox.nim 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  1. ## Copyright 2020 Junekey Jeon
  2. ## Copyright 2020 Alexander Bolz
  3. ##
  4. ## Distributed under the Boost Software License, Version 1.0.
  5. ## (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
  6. ## char* output_end = Dtoa(buffer, value);
  7. ##
  8. ## Converts the given double-precision number into decimal form and stores the result in the given
  9. ## buffer.
  10. ##
  11. ## The buffer must be large enough, i.e. >= DtoaMinBufferLength.
  12. ## The output format is similar to printf("%g").
  13. ## The output is _not_ null-terminted.
  14. ##
  15. ## The output is optimal, i.e. the output string
  16. ## 1. rounds back to the input number when read in (using round-to-nearest-even)
  17. ## 2. is as short as possible,
  18. ## 3. is as close to the input number as possible.
  19. ##
  20. ## Note:
  21. ## This function may temporarily write up to DtoaMinBufferLength characters into the buffer.
  22. import std/private/digitsutils
  23. when defined(nimPreviewSlimSystem):
  24. import std/assertions
  25. const
  26. dtoaMinBufferLength*: cint = 64
  27. ## This file contains an implementation of Junekey Jeon's Dragonbox algorithm.
  28. ##
  29. ## It is a simplified version of the reference implementation found here:
  30. ## https://github.com/jk-jeon/dragonbox
  31. ##
  32. ## The reference implementation also works with single-precision floating-point numbers and
  33. ## has options to configure the rounding mode.
  34. template dragonbox_Assert*(x: untyped): untyped =
  35. assert(x)
  36. # ==================================================================================================
  37. #
  38. # ==================================================================================================
  39. type
  40. ValueType* = float
  41. BitsType* = uint64
  42. type
  43. Double* = object
  44. bits*: BitsType
  45. const ## = p (includes the hidden bit)
  46. significandSize*: int32 = 53
  47. const ## static constexpr int32_t MaxExponent = 1024 - 1 - (SignificandSize - 1);
  48. ## static constexpr int32_t MinExponent = std::numeric_limits<value_type>::min_exponent - 1 - (SignificandSize - 1);
  49. exponentBias*: int32 = 1024 - 1 + (significandSize - 1)
  50. const
  51. maxIeeeExponent*: BitsType = BitsType(2 * 1024 - 1)
  52. const ## = 2^(p-1)
  53. hiddenBit*: BitsType = BitsType(1) shl (significandSize - 1)
  54. const ## = 2^(p-1) - 1
  55. significandMask*: BitsType = hiddenBit - 1
  56. const
  57. exponentMask*: BitsType = maxIeeeExponent shl (significandSize - 1)
  58. const
  59. signMask*: BitsType = not (not BitsType(0) shr 1)
  60. proc constructDouble*(bits: BitsType): Double =
  61. result.bits = bits
  62. proc constructDouble*(value: ValueType): Double =
  63. result.bits = cast[typeof(result.bits)](value)
  64. proc physicalSignificand*(this: Double): BitsType {.noSideEffect.} =
  65. return this.bits and significandMask
  66. proc physicalExponent*(this: Double): BitsType {.noSideEffect.} =
  67. return (this.bits and exponentMask) shr (significandSize - 1)
  68. proc isFinite*(this: Double): bool {.noSideEffect.} =
  69. return (this.bits and exponentMask) != exponentMask
  70. proc isInf*(this: Double): bool {.noSideEffect.} =
  71. return (this.bits and exponentMask) == exponentMask and
  72. (this.bits and significandMask) == 0
  73. proc isNaN*(this: Double): bool {.noSideEffect.} =
  74. return (this.bits and exponentMask) == exponentMask and
  75. (this.bits and significandMask) != 0
  76. proc isZero*(this: Double): bool {.noSideEffect.} =
  77. return (this.bits and not signMask) == 0
  78. proc signBit*(this: Double): int {.noSideEffect.} =
  79. return ord((this.bits and signMask) != 0)
  80. # ==================================================================================================
  81. #
  82. # ==================================================================================================
  83. ## namespace
  84. ## Returns floor(x / 2^n).
  85. ##
  86. ## Technically, right-shift of negative integers is implementation defined...
  87. ## Should easily be optimized into SAR (or equivalent) instruction.
  88. proc floorDivPow2*(x: int32; n: int32): int32 {.inline.} =
  89. return x shr n
  90. proc floorLog2Pow10*(e: int32): int32 {.inline.} =
  91. dragonbox_Assert(e >= -1233)
  92. dragonbox_Assert(e <= 1233)
  93. return floorDivPow2(e * 1741647, 19)
  94. proc floorLog10Pow2*(e: int32): int32 {.inline.} =
  95. dragonbox_Assert(e >= -1500)
  96. dragonbox_Assert(e <= 1500)
  97. return floorDivPow2(e * 1262611, 22)
  98. proc floorLog10ThreeQuartersPow2*(e: int32): int32 {.inline.} =
  99. dragonbox_Assert(e >= -1500)
  100. dragonbox_Assert(e <= 1500)
  101. return floorDivPow2(e * 1262611 - 524031, 22)
  102. # ==================================================================================================
  103. #
  104. # ==================================================================================================
  105. type
  106. uint64x2* {.bycopy.} = object
  107. hi*: uint64
  108. lo*: uint64
  109. proc computePow10*(k: int32): uint64x2 {.inline.} =
  110. const
  111. kMin: int32 = -292
  112. const
  113. kMax: int32 = 326
  114. const
  115. pow10: array[kMax - kMin + 1, uint64x2] = [
  116. uint64x2(hi: 0xFF77B1FCBEBCDC4F'u, lo: 0x25E8E89C13BB0F7B'u),
  117. uint64x2(hi: 0x9FAACF3DF73609B1'u, lo: 0x77B191618C54E9AD'u),
  118. uint64x2(hi: 0xC795830D75038C1D'u, lo: 0xD59DF5B9EF6A2418'u),
  119. uint64x2(hi: 0xF97AE3D0D2446F25'u, lo: 0x4B0573286B44AD1E'u),
  120. uint64x2(hi: 0x9BECCE62836AC577'u, lo: 0x4EE367F9430AEC33'u),
  121. uint64x2(hi: 0xC2E801FB244576D5'u, lo: 0x229C41F793CDA740'u),
  122. uint64x2(hi: 0xF3A20279ED56D48A'u, lo: 0x6B43527578C11110'u),
  123. uint64x2(hi: 0x9845418C345644D6'u, lo: 0x830A13896B78AAAA'u),
  124. uint64x2(hi: 0xBE5691EF416BD60C'u, lo: 0x23CC986BC656D554'u),
  125. uint64x2(hi: 0xEDEC366B11C6CB8F'u, lo: 0x2CBFBE86B7EC8AA9'u),
  126. uint64x2(hi: 0x94B3A202EB1C3F39'u, lo: 0x7BF7D71432F3D6AA'u),
  127. uint64x2(hi: 0xB9E08A83A5E34F07'u, lo: 0xDAF5CCD93FB0CC54'u),
  128. uint64x2(hi: 0xE858AD248F5C22C9'u, lo: 0xD1B3400F8F9CFF69'u),
  129. uint64x2(hi: 0x91376C36D99995BE'u, lo: 0x23100809B9C21FA2'u),
  130. uint64x2(hi: 0xB58547448FFFFB2D'u, lo: 0xABD40A0C2832A78B'u),
  131. uint64x2(hi: 0xE2E69915B3FFF9F9'u, lo: 0x16C90C8F323F516D'u),
  132. uint64x2(hi: 0x8DD01FAD907FFC3B'u, lo: 0xAE3DA7D97F6792E4'u),
  133. uint64x2(hi: 0xB1442798F49FFB4A'u, lo: 0x99CD11CFDF41779D'u),
  134. uint64x2(hi: 0xDD95317F31C7FA1D'u, lo: 0x40405643D711D584'u),
  135. uint64x2(hi: 0x8A7D3EEF7F1CFC52'u, lo: 0x482835EA666B2573'u),
  136. uint64x2(hi: 0xAD1C8EAB5EE43B66'u, lo: 0xDA3243650005EED0'u),
  137. uint64x2(hi: 0xD863B256369D4A40'u, lo: 0x90BED43E40076A83'u),
  138. uint64x2(hi: 0x873E4F75E2224E68'u, lo: 0x5A7744A6E804A292'u),
  139. uint64x2(hi: 0xA90DE3535AAAE202'u, lo: 0x711515D0A205CB37'u),
  140. uint64x2(hi: 0xD3515C2831559A83'u, lo: 0x0D5A5B44CA873E04'u),
  141. uint64x2(hi: 0x8412D9991ED58091'u, lo: 0xE858790AFE9486C3'u),
  142. uint64x2(hi: 0xA5178FFF668AE0B6'u, lo: 0x626E974DBE39A873'u),
  143. uint64x2(hi: 0xCE5D73FF402D98E3'u, lo: 0xFB0A3D212DC81290'u),
  144. uint64x2(hi: 0x80FA687F881C7F8E'u, lo: 0x7CE66634BC9D0B9A'u),
  145. uint64x2(hi: 0xA139029F6A239F72'u, lo: 0x1C1FFFC1EBC44E81'u),
  146. uint64x2(hi: 0xC987434744AC874E'u, lo: 0xA327FFB266B56221'u),
  147. uint64x2(hi: 0xFBE9141915D7A922'u, lo: 0x4BF1FF9F0062BAA9'u),
  148. uint64x2(hi: 0x9D71AC8FADA6C9B5'u, lo: 0x6F773FC3603DB4AA'u),
  149. uint64x2(hi: 0xC4CE17B399107C22'u, lo: 0xCB550FB4384D21D4'u),
  150. uint64x2(hi: 0xF6019DA07F549B2B'u, lo: 0x7E2A53A146606A49'u),
  151. uint64x2(hi: 0x99C102844F94E0FB'u, lo: 0x2EDA7444CBFC426E'u),
  152. uint64x2(hi: 0xC0314325637A1939'u, lo: 0xFA911155FEFB5309'u),
  153. uint64x2(hi: 0xF03D93EEBC589F88'u, lo: 0x793555AB7EBA27CB'u),
  154. uint64x2(hi: 0x96267C7535B763B5'u, lo: 0x4BC1558B2F3458DF'u),
  155. uint64x2(hi: 0xBBB01B9283253CA2'u, lo: 0x9EB1AAEDFB016F17'u),
  156. uint64x2(hi: 0xEA9C227723EE8BCB'u, lo: 0x465E15A979C1CADD'u),
  157. uint64x2(hi: 0x92A1958A7675175F'u, lo: 0x0BFACD89EC191ECA'u),
  158. uint64x2(hi: 0xB749FAED14125D36'u, lo: 0xCEF980EC671F667C'u),
  159. uint64x2(hi: 0xE51C79A85916F484'u, lo: 0x82B7E12780E7401B'u),
  160. uint64x2(hi: 0x8F31CC0937AE58D2'u, lo: 0xD1B2ECB8B0908811'u),
  161. uint64x2(hi: 0xB2FE3F0B8599EF07'u, lo: 0x861FA7E6DCB4AA16'u),
  162. uint64x2(hi: 0xDFBDCECE67006AC9'u, lo: 0x67A791E093E1D49B'u),
  163. uint64x2(hi: 0x8BD6A141006042BD'u, lo: 0xE0C8BB2C5C6D24E1'u),
  164. uint64x2(hi: 0xAECC49914078536D'u, lo: 0x58FAE9F773886E19'u),
  165. uint64x2(hi: 0xDA7F5BF590966848'u, lo: 0xAF39A475506A899F'u),
  166. uint64x2(hi: 0x888F99797A5E012D'u, lo: 0x6D8406C952429604'u),
  167. uint64x2(hi: 0xAAB37FD7D8F58178'u, lo: 0xC8E5087BA6D33B84'u),
  168. uint64x2(hi: 0xD5605FCDCF32E1D6'u, lo: 0xFB1E4A9A90880A65'u),
  169. uint64x2(hi: 0x855C3BE0A17FCD26'u, lo: 0x5CF2EEA09A550680'u),
  170. uint64x2(hi: 0xA6B34AD8C9DFC06F'u, lo: 0xF42FAA48C0EA481F'u),
  171. uint64x2(hi: 0xD0601D8EFC57B08B'u, lo: 0xF13B94DAF124DA27'u),
  172. uint64x2(hi: 0x823C12795DB6CE57'u, lo: 0x76C53D08D6B70859'u),
  173. uint64x2(hi: 0xA2CB1717B52481ED'u, lo: 0x54768C4B0C64CA6F'u),
  174. uint64x2(hi: 0xCB7DDCDDA26DA268'u, lo: 0xA9942F5DCF7DFD0A'u),
  175. uint64x2(hi: 0xFE5D54150B090B02'u, lo: 0xD3F93B35435D7C4D'u),
  176. uint64x2(hi: 0x9EFA548D26E5A6E1'u, lo: 0xC47BC5014A1A6DB0'u),
  177. uint64x2(hi: 0xC6B8E9B0709F109A'u, lo: 0x359AB6419CA1091C'u),
  178. uint64x2(hi: 0xF867241C8CC6D4C0'u, lo: 0xC30163D203C94B63'u),
  179. uint64x2(hi: 0x9B407691D7FC44F8'u, lo: 0x79E0DE63425DCF1E'u),
  180. uint64x2(hi: 0xC21094364DFB5636'u, lo: 0x985915FC12F542E5'u),
  181. uint64x2(hi: 0xF294B943E17A2BC4'u, lo: 0x3E6F5B7B17B2939E'u),
  182. uint64x2(hi: 0x979CF3CA6CEC5B5A'u, lo: 0xA705992CEECF9C43'u),
  183. uint64x2(hi: 0xBD8430BD08277231'u, lo: 0x50C6FF782A838354'u),
  184. uint64x2(hi: 0xECE53CEC4A314EBD'u, lo: 0xA4F8BF5635246429'u),
  185. uint64x2(hi: 0x940F4613AE5ED136'u, lo: 0x871B7795E136BE9A'u),
  186. uint64x2(hi: 0xB913179899F68584'u, lo: 0x28E2557B59846E40'u),
  187. uint64x2(hi: 0xE757DD7EC07426E5'u, lo: 0x331AEADA2FE589D0'u),
  188. uint64x2(hi: 0x9096EA6F3848984F'u, lo: 0x3FF0D2C85DEF7622'u),
  189. uint64x2(hi: 0xB4BCA50B065ABE63'u, lo: 0x0FED077A756B53AA'u),
  190. uint64x2(hi: 0xE1EBCE4DC7F16DFB'u, lo: 0xD3E8495912C62895'u),
  191. uint64x2(hi: 0x8D3360F09CF6E4BD'u, lo: 0x64712DD7ABBBD95D'u),
  192. uint64x2(hi: 0xB080392CC4349DEC'u, lo: 0xBD8D794D96AACFB4'u),
  193. uint64x2(hi: 0xDCA04777F541C567'u, lo: 0xECF0D7A0FC5583A1'u),
  194. uint64x2(hi: 0x89E42CAAF9491B60'u, lo: 0xF41686C49DB57245'u),
  195. uint64x2(hi: 0xAC5D37D5B79B6239'u, lo: 0x311C2875C522CED6'u),
  196. uint64x2(hi: 0xD77485CB25823AC7'u, lo: 0x7D633293366B828C'u),
  197. uint64x2(hi: 0x86A8D39EF77164BC'u, lo: 0xAE5DFF9C02033198'u),
  198. uint64x2(hi: 0xA8530886B54DBDEB'u, lo: 0xD9F57F830283FDFD'u),
  199. uint64x2(hi: 0xD267CAA862A12D66'u, lo: 0xD072DF63C324FD7C'u),
  200. uint64x2(hi: 0x8380DEA93DA4BC60'u, lo: 0x4247CB9E59F71E6E'u),
  201. uint64x2(hi: 0xA46116538D0DEB78'u, lo: 0x52D9BE85F074E609'u),
  202. uint64x2(hi: 0xCD795BE870516656'u, lo: 0x67902E276C921F8C'u),
  203. uint64x2(hi: 0x806BD9714632DFF6'u, lo: 0x00BA1CD8A3DB53B7'u),
  204. uint64x2(hi: 0xA086CFCD97BF97F3'u, lo: 0x80E8A40ECCD228A5'u),
  205. uint64x2(hi: 0xC8A883C0FDAF7DF0'u, lo: 0x6122CD128006B2CE'u),
  206. uint64x2(hi: 0xFAD2A4B13D1B5D6C'u, lo: 0x796B805720085F82'u),
  207. uint64x2(hi: 0x9CC3A6EEC6311A63'u, lo: 0xCBE3303674053BB1'u),
  208. uint64x2(hi: 0xC3F490AA77BD60FC'u, lo: 0xBEDBFC4411068A9D'u),
  209. uint64x2(hi: 0xF4F1B4D515ACB93B'u, lo: 0xEE92FB5515482D45'u),
  210. uint64x2(hi: 0x991711052D8BF3C5'u, lo: 0x751BDD152D4D1C4B'u),
  211. uint64x2(hi: 0xBF5CD54678EEF0B6'u, lo: 0xD262D45A78A0635E'u),
  212. uint64x2(hi: 0xEF340A98172AACE4'u, lo: 0x86FB897116C87C35'u),
  213. uint64x2(hi: 0x9580869F0E7AAC0E'u, lo: 0xD45D35E6AE3D4DA1'u),
  214. uint64x2(hi: 0xBAE0A846D2195712'u, lo: 0x8974836059CCA10A'u),
  215. uint64x2(hi: 0xE998D258869FACD7'u, lo: 0x2BD1A438703FC94C'u),
  216. uint64x2(hi: 0x91FF83775423CC06'u, lo: 0x7B6306A34627DDD0'u),
  217. uint64x2(hi: 0xB67F6455292CBF08'u, lo: 0x1A3BC84C17B1D543'u),
  218. uint64x2(hi: 0xE41F3D6A7377EECA'u, lo: 0x20CABA5F1D9E4A94'u),
  219. uint64x2(hi: 0x8E938662882AF53E'u, lo: 0x547EB47B7282EE9D'u),
  220. uint64x2(hi: 0xB23867FB2A35B28D'u, lo: 0xE99E619A4F23AA44'u),
  221. uint64x2(hi: 0xDEC681F9F4C31F31'u, lo: 0x6405FA00E2EC94D5'u),
  222. uint64x2(hi: 0x8B3C113C38F9F37E'u, lo: 0xDE83BC408DD3DD05'u),
  223. uint64x2(hi: 0xAE0B158B4738705E'u, lo: 0x9624AB50B148D446'u),
  224. uint64x2(hi: 0xD98DDAEE19068C76'u, lo: 0x3BADD624DD9B0958'u),
  225. uint64x2(hi: 0x87F8A8D4CFA417C9'u, lo: 0xE54CA5D70A80E5D7'u),
  226. uint64x2(hi: 0xA9F6D30A038D1DBC'u, lo: 0x5E9FCF4CCD211F4D'u),
  227. uint64x2(hi: 0xD47487CC8470652B'u, lo: 0x7647C32000696720'u),
  228. uint64x2(hi: 0x84C8D4DFD2C63F3B'u, lo: 0x29ECD9F40041E074'u),
  229. uint64x2(hi: 0xA5FB0A17C777CF09'u, lo: 0xF468107100525891'u),
  230. uint64x2(hi: 0xCF79CC9DB955C2CC'u, lo: 0x7182148D4066EEB5'u),
  231. uint64x2(hi: 0x81AC1FE293D599BF'u, lo: 0xC6F14CD848405531'u),
  232. uint64x2(hi: 0xA21727DB38CB002F'u, lo: 0xB8ADA00E5A506A7D'u),
  233. uint64x2(hi: 0xCA9CF1D206FDC03B'u, lo: 0xA6D90811F0E4851D'u),
  234. uint64x2(hi: 0xFD442E4688BD304A'u, lo: 0x908F4A166D1DA664'u),
  235. uint64x2(hi: 0x9E4A9CEC15763E2E'u, lo: 0x9A598E4E043287FF'u),
  236. uint64x2(hi: 0xC5DD44271AD3CDBA'u, lo: 0x40EFF1E1853F29FE'u),
  237. uint64x2(hi: 0xF7549530E188C128'u, lo: 0xD12BEE59E68EF47D'u),
  238. uint64x2(hi: 0x9A94DD3E8CF578B9'u, lo: 0x82BB74F8301958CF'u),
  239. uint64x2(hi: 0xC13A148E3032D6E7'u, lo: 0xE36A52363C1FAF02'u),
  240. uint64x2(hi: 0xF18899B1BC3F8CA1'u, lo: 0xDC44E6C3CB279AC2'u),
  241. uint64x2(hi: 0x96F5600F15A7B7E5'u, lo: 0x29AB103A5EF8C0BA'u),
  242. uint64x2(hi: 0xBCB2B812DB11A5DE'u, lo: 0x7415D448F6B6F0E8'u),
  243. uint64x2(hi: 0xEBDF661791D60F56'u, lo: 0x111B495B3464AD22'u),
  244. uint64x2(hi: 0x936B9FCEBB25C995'u, lo: 0xCAB10DD900BEEC35'u),
  245. uint64x2(hi: 0xB84687C269EF3BFB'u, lo: 0x3D5D514F40EEA743'u),
  246. uint64x2(hi: 0xE65829B3046B0AFA'u, lo: 0x0CB4A5A3112A5113'u),
  247. uint64x2(hi: 0x8FF71A0FE2C2E6DC'u, lo: 0x47F0E785EABA72AC'u),
  248. uint64x2(hi: 0xB3F4E093DB73A093'u, lo: 0x59ED216765690F57'u),
  249. uint64x2(hi: 0xE0F218B8D25088B8'u, lo: 0x306869C13EC3532D'u),
  250. uint64x2(hi: 0x8C974F7383725573'u, lo: 0x1E414218C73A13FC'u),
  251. uint64x2(hi: 0xAFBD2350644EEACF'u, lo: 0xE5D1929EF90898FB'u),
  252. uint64x2(hi: 0xDBAC6C247D62A583'u, lo: 0xDF45F746B74ABF3A'u),
  253. uint64x2(hi: 0x894BC396CE5DA772'u, lo: 0x6B8BBA8C328EB784'u),
  254. uint64x2(hi: 0xAB9EB47C81F5114F'u, lo: 0x066EA92F3F326565'u),
  255. uint64x2(hi: 0xD686619BA27255A2'u, lo: 0xC80A537B0EFEFEBE'u),
  256. uint64x2(hi: 0x8613FD0145877585'u, lo: 0xBD06742CE95F5F37'u),
  257. uint64x2(hi: 0xA798FC4196E952E7'u, lo: 0x2C48113823B73705'u),
  258. uint64x2(hi: 0xD17F3B51FCA3A7A0'u, lo: 0xF75A15862CA504C6'u),
  259. uint64x2(hi: 0x82EF85133DE648C4'u, lo: 0x9A984D73DBE722FC'u),
  260. uint64x2(hi: 0xA3AB66580D5FDAF5'u, lo: 0xC13E60D0D2E0EBBB'u),
  261. uint64x2(hi: 0xCC963FEE10B7D1B3'u, lo: 0x318DF905079926A9'u),
  262. uint64x2(hi: 0xFFBBCFE994E5C61F'u, lo: 0xFDF17746497F7053'u),
  263. uint64x2(hi: 0x9FD561F1FD0F9BD3'u, lo: 0xFEB6EA8BEDEFA634'u),
  264. uint64x2(hi: 0xC7CABA6E7C5382C8'u, lo: 0xFE64A52EE96B8FC1'u),
  265. uint64x2(hi: 0xF9BD690A1B68637B'u, lo: 0x3DFDCE7AA3C673B1'u),
  266. uint64x2(hi: 0x9C1661A651213E2D'u, lo: 0x06BEA10CA65C084F'u),
  267. uint64x2(hi: 0xC31BFA0FE5698DB8'u, lo: 0x486E494FCFF30A63'u),
  268. uint64x2(hi: 0xF3E2F893DEC3F126'u, lo: 0x5A89DBA3C3EFCCFB'u),
  269. uint64x2(hi: 0x986DDB5C6B3A76B7'u, lo: 0xF89629465A75E01D'u),
  270. uint64x2(hi: 0xBE89523386091465'u, lo: 0xF6BBB397F1135824'u),
  271. uint64x2(hi: 0xEE2BA6C0678B597F'u, lo: 0x746AA07DED582E2D'u),
  272. uint64x2(hi: 0x94DB483840B717EF'u, lo: 0xA8C2A44EB4571CDD'u),
  273. uint64x2(hi: 0xBA121A4650E4DDEB'u, lo: 0x92F34D62616CE414'u),
  274. uint64x2(hi: 0xE896A0D7E51E1566'u, lo: 0x77B020BAF9C81D18'u),
  275. uint64x2(hi: 0x915E2486EF32CD60'u, lo: 0x0ACE1474DC1D122F'u),
  276. uint64x2(hi: 0xB5B5ADA8AAFF80B8'u, lo: 0x0D819992132456BB'u),
  277. uint64x2(hi: 0xE3231912D5BF60E6'u, lo: 0x10E1FFF697ED6C6A'u),
  278. uint64x2(hi: 0x8DF5EFABC5979C8F'u, lo: 0xCA8D3FFA1EF463C2'u),
  279. uint64x2(hi: 0xB1736B96B6FD83B3'u, lo: 0xBD308FF8A6B17CB3'u),
  280. uint64x2(hi: 0xDDD0467C64BCE4A0'u, lo: 0xAC7CB3F6D05DDBDF'u),
  281. uint64x2(hi: 0x8AA22C0DBEF60EE4'u, lo: 0x6BCDF07A423AA96C'u),
  282. uint64x2(hi: 0xAD4AB7112EB3929D'u, lo: 0x86C16C98D2C953C7'u),
  283. uint64x2(hi: 0xD89D64D57A607744'u, lo: 0xE871C7BF077BA8B8'u),
  284. uint64x2(hi: 0x87625F056C7C4A8B'u, lo: 0x11471CD764AD4973'u),
  285. uint64x2(hi: 0xA93AF6C6C79B5D2D'u, lo: 0xD598E40D3DD89BD0'u),
  286. uint64x2(hi: 0xD389B47879823479'u, lo: 0x4AFF1D108D4EC2C4'u),
  287. uint64x2(hi: 0x843610CB4BF160CB'u, lo: 0xCEDF722A585139BB'u),
  288. uint64x2(hi: 0xA54394FE1EEDB8FE'u, lo: 0xC2974EB4EE658829'u),
  289. uint64x2(hi: 0xCE947A3DA6A9273E'u, lo: 0x733D226229FEEA33'u),
  290. uint64x2(hi: 0x811CCC668829B887'u, lo: 0x0806357D5A3F5260'u),
  291. uint64x2(hi: 0xA163FF802A3426A8'u, lo: 0xCA07C2DCB0CF26F8'u),
  292. uint64x2(hi: 0xC9BCFF6034C13052'u, lo: 0xFC89B393DD02F0B6'u),
  293. uint64x2(hi: 0xFC2C3F3841F17C67'u, lo: 0xBBAC2078D443ACE3'u),
  294. uint64x2(hi: 0x9D9BA7832936EDC0'u, lo: 0xD54B944B84AA4C0E'u),
  295. uint64x2(hi: 0xC5029163F384A931'u, lo: 0x0A9E795E65D4DF12'u),
  296. uint64x2(hi: 0xF64335BCF065D37D'u, lo: 0x4D4617B5FF4A16D6'u),
  297. uint64x2(hi: 0x99EA0196163FA42E'u, lo: 0x504BCED1BF8E4E46'u),
  298. uint64x2(hi: 0xC06481FB9BCF8D39'u, lo: 0xE45EC2862F71E1D7'u),
  299. uint64x2(hi: 0xF07DA27A82C37088'u, lo: 0x5D767327BB4E5A4D'u),
  300. uint64x2(hi: 0x964E858C91BA2655'u, lo: 0x3A6A07F8D510F870'u),
  301. uint64x2(hi: 0xBBE226EFB628AFEA'u, lo: 0x890489F70A55368C'u),
  302. uint64x2(hi: 0xEADAB0ABA3B2DBE5'u, lo: 0x2B45AC74CCEA842F'u),
  303. uint64x2(hi: 0x92C8AE6B464FC96F'u, lo: 0x3B0B8BC90012929E'u),
  304. uint64x2(hi: 0xB77ADA0617E3BBCB'u, lo: 0x09CE6EBB40173745'u),
  305. uint64x2(hi: 0xE55990879DDCAABD'u, lo: 0xCC420A6A101D0516'u),
  306. uint64x2(hi: 0x8F57FA54C2A9EAB6'u, lo: 0x9FA946824A12232E'u),
  307. uint64x2(hi: 0xB32DF8E9F3546564'u, lo: 0x47939822DC96ABFA'u),
  308. uint64x2(hi: 0xDFF9772470297EBD'u, lo: 0x59787E2B93BC56F8'u),
  309. uint64x2(hi: 0x8BFBEA76C619EF36'u, lo: 0x57EB4EDB3C55B65B'u),
  310. uint64x2(hi: 0xAEFAE51477A06B03'u, lo: 0xEDE622920B6B23F2'u),
  311. uint64x2(hi: 0xDAB99E59958885C4'u, lo: 0xE95FAB368E45ECEE'u),
  312. uint64x2(hi: 0x88B402F7FD75539B'u, lo: 0x11DBCB0218EBB415'u),
  313. uint64x2(hi: 0xAAE103B5FCD2A881'u, lo: 0xD652BDC29F26A11A'u),
  314. uint64x2(hi: 0xD59944A37C0752A2'u, lo: 0x4BE76D3346F04960'u),
  315. uint64x2(hi: 0x857FCAE62D8493A5'u, lo: 0x6F70A4400C562DDC'u),
  316. uint64x2(hi: 0xA6DFBD9FB8E5B88E'u, lo: 0xCB4CCD500F6BB953'u),
  317. uint64x2(hi: 0xD097AD07A71F26B2'u, lo: 0x7E2000A41346A7A8'u),
  318. uint64x2(hi: 0x825ECC24C873782F'u, lo: 0x8ED400668C0C28C9'u),
  319. uint64x2(hi: 0xA2F67F2DFA90563B'u, lo: 0x728900802F0F32FB'u),
  320. uint64x2(hi: 0xCBB41EF979346BCA'u, lo: 0x4F2B40A03AD2FFBA'u),
  321. uint64x2(hi: 0xFEA126B7D78186BC'u, lo: 0xE2F610C84987BFA9'u),
  322. uint64x2(hi: 0x9F24B832E6B0F436'u, lo: 0x0DD9CA7D2DF4D7CA'u),
  323. uint64x2(hi: 0xC6EDE63FA05D3143'u, lo: 0x91503D1C79720DBC'u),
  324. uint64x2(hi: 0xF8A95FCF88747D94'u, lo: 0x75A44C6397CE912B'u),
  325. uint64x2(hi: 0x9B69DBE1B548CE7C'u, lo: 0xC986AFBE3EE11ABB'u),
  326. uint64x2(hi: 0xC24452DA229B021B'u, lo: 0xFBE85BADCE996169'u),
  327. uint64x2(hi: 0xF2D56790AB41C2A2'u, lo: 0xFAE27299423FB9C4'u),
  328. uint64x2(hi: 0x97C560BA6B0919A5'u, lo: 0xDCCD879FC967D41B'u),
  329. uint64x2(hi: 0xBDB6B8E905CB600F'u, lo: 0x5400E987BBC1C921'u),
  330. uint64x2(hi: 0xED246723473E3813'u, lo: 0x290123E9AAB23B69'u),
  331. uint64x2(hi: 0x9436C0760C86E30B'u, lo: 0xF9A0B6720AAF6522'u),
  332. uint64x2(hi: 0xB94470938FA89BCE'u, lo: 0xF808E40E8D5B3E6A'u),
  333. uint64x2(hi: 0xE7958CB87392C2C2'u, lo: 0xB60B1D1230B20E05'u),
  334. uint64x2(hi: 0x90BD77F3483BB9B9'u, lo: 0xB1C6F22B5E6F48C3'u),
  335. uint64x2(hi: 0xB4ECD5F01A4AA828'u, lo: 0x1E38AEB6360B1AF4'u),
  336. uint64x2(hi: 0xE2280B6C20DD5232'u, lo: 0x25C6DA63C38DE1B1'u),
  337. uint64x2(hi: 0x8D590723948A535F'u, lo: 0x579C487E5A38AD0F'u),
  338. uint64x2(hi: 0xB0AF48EC79ACE837'u, lo: 0x2D835A9DF0C6D852'u),
  339. uint64x2(hi: 0xDCDB1B2798182244'u, lo: 0xF8E431456CF88E66'u),
  340. uint64x2(hi: 0x8A08F0F8BF0F156B'u, lo: 0x1B8E9ECB641B5900'u),
  341. uint64x2(hi: 0xAC8B2D36EED2DAC5'u, lo: 0xE272467E3D222F40'u),
  342. uint64x2(hi: 0xD7ADF884AA879177'u, lo: 0x5B0ED81DCC6ABB10'u),
  343. uint64x2(hi: 0x86CCBB52EA94BAEA'u, lo: 0x98E947129FC2B4EA'u),
  344. uint64x2(hi: 0xA87FEA27A539E9A5'u, lo: 0x3F2398D747B36225'u),
  345. uint64x2(hi: 0xD29FE4B18E88640E'u, lo: 0x8EEC7F0D19A03AAE'u),
  346. uint64x2(hi: 0x83A3EEEEF9153E89'u, lo: 0x1953CF68300424AD'u),
  347. uint64x2(hi: 0xA48CEAAAB75A8E2B'u, lo: 0x5FA8C3423C052DD8'u),
  348. uint64x2(hi: 0xCDB02555653131B6'u, lo: 0x3792F412CB06794E'u),
  349. uint64x2(hi: 0x808E17555F3EBF11'u, lo: 0xE2BBD88BBEE40BD1'u),
  350. uint64x2(hi: 0xA0B19D2AB70E6ED6'u, lo: 0x5B6ACEAEAE9D0EC5'u),
  351. uint64x2(hi: 0xC8DE047564D20A8B'u, lo: 0xF245825A5A445276'u),
  352. uint64x2(hi: 0xFB158592BE068D2E'u, lo: 0xEED6E2F0F0D56713'u),
  353. uint64x2(hi: 0x9CED737BB6C4183D'u, lo: 0x55464DD69685606C'u),
  354. uint64x2(hi: 0xC428D05AA4751E4C'u, lo: 0xAA97E14C3C26B887'u),
  355. uint64x2(hi: 0xF53304714D9265DF'u, lo: 0xD53DD99F4B3066A9'u),
  356. uint64x2(hi: 0x993FE2C6D07B7FAB'u, lo: 0xE546A8038EFE402A'u),
  357. uint64x2(hi: 0xBF8FDB78849A5F96'u, lo: 0xDE98520472BDD034'u),
  358. uint64x2(hi: 0xEF73D256A5C0F77C'u, lo: 0x963E66858F6D4441'u),
  359. uint64x2(hi: 0x95A8637627989AAD'u, lo: 0xDDE7001379A44AA9'u),
  360. uint64x2(hi: 0xBB127C53B17EC159'u, lo: 0x5560C018580D5D53'u),
  361. uint64x2(hi: 0xE9D71B689DDE71AF'u, lo: 0xAAB8F01E6E10B4A7'u),
  362. uint64x2(hi: 0x9226712162AB070D'u, lo: 0xCAB3961304CA70E9'u),
  363. uint64x2(hi: 0xB6B00D69BB55C8D1'u, lo: 0x3D607B97C5FD0D23'u),
  364. uint64x2(hi: 0xE45C10C42A2B3B05'u, lo: 0x8CB89A7DB77C506B'u),
  365. uint64x2(hi: 0x8EB98A7A9A5B04E3'u, lo: 0x77F3608E92ADB243'u),
  366. uint64x2(hi: 0xB267ED1940F1C61C'u, lo: 0x55F038B237591ED4'u),
  367. uint64x2(hi: 0xDF01E85F912E37A3'u, lo: 0x6B6C46DEC52F6689'u),
  368. uint64x2(hi: 0x8B61313BBABCE2C6'u, lo: 0x2323AC4B3B3DA016'u),
  369. uint64x2(hi: 0xAE397D8AA96C1B77'u, lo: 0xABEC975E0A0D081B'u),
  370. uint64x2(hi: 0xD9C7DCED53C72255'u, lo: 0x96E7BD358C904A22'u),
  371. uint64x2(hi: 0x881CEA14545C7575'u, lo: 0x7E50D64177DA2E55'u),
  372. uint64x2(hi: 0xAA242499697392D2'u, lo: 0xDDE50BD1D5D0B9EA'u),
  373. uint64x2(hi: 0xD4AD2DBFC3D07787'u, lo: 0x955E4EC64B44E865'u),
  374. uint64x2(hi: 0x84EC3C97DA624AB4'u, lo: 0xBD5AF13BEF0B113F'u),
  375. uint64x2(hi: 0xA6274BBDD0FADD61'u, lo: 0xECB1AD8AEACDD58F'u),
  376. uint64x2(hi: 0xCFB11EAD453994BA'u, lo: 0x67DE18EDA5814AF3'u),
  377. uint64x2(hi: 0x81CEB32C4B43FCF4'u, lo: 0x80EACF948770CED8'u),
  378. uint64x2(hi: 0xA2425FF75E14FC31'u, lo: 0xA1258379A94D028E'u),
  379. uint64x2(hi: 0xCAD2F7F5359A3B3E'u, lo: 0x096EE45813A04331'u),
  380. uint64x2(hi: 0xFD87B5F28300CA0D'u, lo: 0x8BCA9D6E188853FD'u),
  381. uint64x2(hi: 0x9E74D1B791E07E48'u, lo: 0x775EA264CF55347E'u),
  382. uint64x2(hi: 0xC612062576589DDA'u, lo: 0x95364AFE032A819E'u),
  383. uint64x2(hi: 0xF79687AED3EEC551'u, lo: 0x3A83DDBD83F52205'u),
  384. uint64x2(hi: 0x9ABE14CD44753B52'u, lo: 0xC4926A9672793543'u),
  385. uint64x2(hi: 0xC16D9A0095928A27'u, lo: 0x75B7053C0F178294'u),
  386. uint64x2(hi: 0xF1C90080BAF72CB1'u, lo: 0x5324C68B12DD6339'u),
  387. uint64x2(hi: 0x971DA05074DA7BEE'u, lo: 0xD3F6FC16EBCA5E04'u),
  388. uint64x2(hi: 0xBCE5086492111AEA'u, lo: 0x88F4BB1CA6BCF585'u),
  389. uint64x2(hi: 0xEC1E4A7DB69561A5'u, lo: 0x2B31E9E3D06C32E6'u),
  390. uint64x2(hi: 0x9392EE8E921D5D07'u, lo: 0x3AFF322E62439FD0'u),
  391. uint64x2(hi: 0xB877AA3236A4B449'u, lo: 0x09BEFEB9FAD487C3'u),
  392. uint64x2(hi: 0xE69594BEC44DE15B'u, lo: 0x4C2EBE687989A9B4'u),
  393. uint64x2(hi: 0x901D7CF73AB0ACD9'u, lo: 0x0F9D37014BF60A11'u),
  394. uint64x2(hi: 0xB424DC35095CD80F'u, lo: 0x538484C19EF38C95'u),
  395. uint64x2(hi: 0xE12E13424BB40E13'u, lo: 0x2865A5F206B06FBA'u),
  396. uint64x2(hi: 0x8CBCCC096F5088CB'u, lo: 0xF93F87B7442E45D4'u),
  397. uint64x2(hi: 0xAFEBFF0BCB24AAFE'u, lo: 0xF78F69A51539D749'u),
  398. uint64x2(hi: 0xDBE6FECEBDEDD5BE'u, lo: 0xB573440E5A884D1C'u),
  399. uint64x2(hi: 0x89705F4136B4A597'u, lo: 0x31680A88F8953031'u),
  400. uint64x2(hi: 0xABCC77118461CEFC'u, lo: 0xFDC20D2B36BA7C3E'u),
  401. uint64x2(hi: 0xD6BF94D5E57A42BC'u, lo: 0x3D32907604691B4D'u),
  402. uint64x2(hi: 0x8637BD05AF6C69B5'u, lo: 0xA63F9A49C2C1B110'u),
  403. uint64x2(hi: 0xA7C5AC471B478423'u, lo: 0x0FCF80DC33721D54'u),
  404. uint64x2(hi: 0xD1B71758E219652B'u, lo: 0xD3C36113404EA4A9'u),
  405. uint64x2(hi: 0x83126E978D4FDF3B'u, lo: 0x645A1CAC083126EA'u),
  406. uint64x2(hi: 0xA3D70A3D70A3D70A'u, lo: 0x3D70A3D70A3D70A4'u),
  407. uint64x2(hi: 0xCCCCCCCCCCCCCCCC'u, lo: 0xCCCCCCCCCCCCCCCD'u),
  408. uint64x2(hi: 0x8000000000000000'u, lo: 0x0000000000000000'u),
  409. uint64x2(hi: 0xA000000000000000'u, lo: 0x0000000000000000'u),
  410. uint64x2(hi: 0xC800000000000000'u, lo: 0x0000000000000000'u),
  411. uint64x2(hi: 0xFA00000000000000'u, lo: 0x0000000000000000'u),
  412. uint64x2(hi: 0x9C40000000000000'u, lo: 0x0000000000000000'u),
  413. uint64x2(hi: 0xC350000000000000'u, lo: 0x0000000000000000'u),
  414. uint64x2(hi: 0xF424000000000000'u, lo: 0x0000000000000000'u),
  415. uint64x2(hi: 0x9896800000000000'u, lo: 0x0000000000000000'u),
  416. uint64x2(hi: 0xBEBC200000000000'u, lo: 0x0000000000000000'u),
  417. uint64x2(hi: 0xEE6B280000000000'u, lo: 0x0000000000000000'u),
  418. uint64x2(hi: 0x9502F90000000000'u, lo: 0x0000000000000000'u),
  419. uint64x2(hi: 0xBA43B74000000000'u, lo: 0x0000000000000000'u),
  420. uint64x2(hi: 0xE8D4A51000000000'u, lo: 0x0000000000000000'u),
  421. uint64x2(hi: 0x9184E72A00000000'u, lo: 0x0000000000000000'u),
  422. uint64x2(hi: 0xB5E620F480000000'u, lo: 0x0000000000000000'u),
  423. uint64x2(hi: 0xE35FA931A0000000'u, lo: 0x0000000000000000'u),
  424. uint64x2(hi: 0x8E1BC9BF04000000'u, lo: 0x0000000000000000'u),
  425. uint64x2(hi: 0xB1A2BC2EC5000000'u, lo: 0x0000000000000000'u),
  426. uint64x2(hi: 0xDE0B6B3A76400000'u, lo: 0x0000000000000000'u),
  427. uint64x2(hi: 0x8AC7230489E80000'u, lo: 0x0000000000000000'u),
  428. uint64x2(hi: 0xAD78EBC5AC620000'u, lo: 0x0000000000000000'u),
  429. uint64x2(hi: 0xD8D726B7177A8000'u, lo: 0x0000000000000000'u),
  430. uint64x2(hi: 0x878678326EAC9000'u, lo: 0x0000000000000000'u),
  431. uint64x2(hi: 0xA968163F0A57B400'u, lo: 0x0000000000000000'u),
  432. uint64x2(hi: 0xD3C21BCECCEDA100'u, lo: 0x0000000000000000'u),
  433. uint64x2(hi: 0x84595161401484A0'u, lo: 0x0000000000000000'u),
  434. uint64x2(hi: 0xA56FA5B99019A5C8'u, lo: 0x0000000000000000'u),
  435. uint64x2(hi: 0xCECB8F27F4200F3A'u, lo: 0x0000000000000000'u),
  436. uint64x2(hi: 0x813F3978F8940984'u, lo: 0x4000000000000000'u),
  437. uint64x2(hi: 0xA18F07D736B90BE5'u, lo: 0x5000000000000000'u),
  438. uint64x2(hi: 0xC9F2C9CD04674EDE'u, lo: 0xA400000000000000'u),
  439. uint64x2(hi: 0xFC6F7C4045812296'u, lo: 0x4D00000000000000'u),
  440. uint64x2(hi: 0x9DC5ADA82B70B59D'u, lo: 0xF020000000000000'u),
  441. uint64x2(hi: 0xC5371912364CE305'u, lo: 0x6C28000000000000'u),
  442. uint64x2(hi: 0xF684DF56C3E01BC6'u, lo: 0xC732000000000000'u),
  443. uint64x2(hi: 0x9A130B963A6C115C'u, lo: 0x3C7F400000000000'u),
  444. uint64x2(hi: 0xC097CE7BC90715B3'u, lo: 0x4B9F100000000000'u),
  445. uint64x2(hi: 0xF0BDC21ABB48DB20'u, lo: 0x1E86D40000000000'u),
  446. uint64x2(hi: 0x96769950B50D88F4'u, lo: 0x1314448000000000'u),
  447. uint64x2(hi: 0xBC143FA4E250EB31'u, lo: 0x17D955A000000000'u),
  448. uint64x2(hi: 0xEB194F8E1AE525FD'u, lo: 0x5DCFAB0800000000'u),
  449. uint64x2(hi: 0x92EFD1B8D0CF37BE'u, lo: 0x5AA1CAE500000000'u),
  450. uint64x2(hi: 0xB7ABC627050305AD'u, lo: 0xF14A3D9E40000000'u),
  451. uint64x2(hi: 0xE596B7B0C643C719'u, lo: 0x6D9CCD05D0000000'u),
  452. uint64x2(hi: 0x8F7E32CE7BEA5C6F'u, lo: 0xE4820023A2000000'u),
  453. uint64x2(hi: 0xB35DBF821AE4F38B'u, lo: 0xDDA2802C8A800000'u),
  454. uint64x2(hi: 0xE0352F62A19E306E'u, lo: 0xD50B2037AD200000'u),
  455. uint64x2(hi: 0x8C213D9DA502DE45'u, lo: 0x4526F422CC340000'u),
  456. uint64x2(hi: 0xAF298D050E4395D6'u, lo: 0x9670B12B7F410000'u),
  457. uint64x2(hi: 0xDAF3F04651D47B4C'u, lo: 0x3C0CDD765F114000'u),
  458. uint64x2(hi: 0x88D8762BF324CD0F'u, lo: 0xA5880A69FB6AC800'u),
  459. uint64x2(hi: 0xAB0E93B6EFEE0053'u, lo: 0x8EEA0D047A457A00'u),
  460. uint64x2(hi: 0xD5D238A4ABE98068'u, lo: 0x72A4904598D6D880'u),
  461. uint64x2(hi: 0x85A36366EB71F041'u, lo: 0x47A6DA2B7F864750'u),
  462. uint64x2(hi: 0xA70C3C40A64E6C51'u, lo: 0x999090B65F67D924'u),
  463. uint64x2(hi: 0xD0CF4B50CFE20765'u, lo: 0xFFF4B4E3F741CF6D'u),
  464. uint64x2(hi: 0x82818F1281ED449F'u, lo: 0xBFF8F10E7A8921A4'u),
  465. uint64x2(hi: 0xA321F2D7226895C7'u, lo: 0xAFF72D52192B6A0D'u),
  466. uint64x2(hi: 0xCBEA6F8CEB02BB39'u, lo: 0x9BF4F8A69F764490'u),
  467. uint64x2(hi: 0xFEE50B7025C36A08'u, lo: 0x02F236D04753D5B4'u),
  468. uint64x2(hi: 0x9F4F2726179A2245'u, lo: 0x01D762422C946590'u),
  469. uint64x2(hi: 0xC722F0EF9D80AAD6'u, lo: 0x424D3AD2B7B97EF5'u),
  470. uint64x2(hi: 0xF8EBAD2B84E0D58B'u, lo: 0xD2E0898765A7DEB2'u),
  471. uint64x2(hi: 0x9B934C3B330C8577'u, lo: 0x63CC55F49F88EB2F'u),
  472. uint64x2(hi: 0xC2781F49FFCFA6D5'u, lo: 0x3CBF6B71C76B25FB'u),
  473. uint64x2(hi: 0xF316271C7FC3908A'u, lo: 0x8BEF464E3945EF7A'u),
  474. uint64x2(hi: 0x97EDD871CFDA3A56'u, lo: 0x97758BF0E3CBB5AC'u),
  475. uint64x2(hi: 0xBDE94E8E43D0C8EC'u, lo: 0x3D52EEED1CBEA317'u),
  476. uint64x2(hi: 0xED63A231D4C4FB27'u, lo: 0x4CA7AAA863EE4BDD'u),
  477. uint64x2(hi: 0x945E455F24FB1CF8'u, lo: 0x8FE8CAA93E74EF6A'u),
  478. uint64x2(hi: 0xB975D6B6EE39E436'u, lo: 0xB3E2FD538E122B44'u),
  479. uint64x2(hi: 0xE7D34C64A9C85D44'u, lo: 0x60DBBCA87196B616'u),
  480. uint64x2(hi: 0x90E40FBEEA1D3A4A'u, lo: 0xBC8955E946FE31CD'u),
  481. uint64x2(hi: 0xB51D13AEA4A488DD'u, lo: 0x6BABAB6398BDBE41'u),
  482. uint64x2(hi: 0xE264589A4DCDAB14'u, lo: 0xC696963C7EED2DD1'u),
  483. uint64x2(hi: 0x8D7EB76070A08AEC'u, lo: 0xFC1E1DE5CF543CA2'u),
  484. uint64x2(hi: 0xB0DE65388CC8ADA8'u, lo: 0x3B25A55F43294BCB'u),
  485. uint64x2(hi: 0xDD15FE86AFFAD912'u, lo: 0x49EF0EB713F39EBE'u),
  486. uint64x2(hi: 0x8A2DBF142DFCC7AB'u, lo: 0x6E3569326C784337'u),
  487. uint64x2(hi: 0xACB92ED9397BF996'u, lo: 0x49C2C37F07965404'u),
  488. uint64x2(hi: 0xD7E77A8F87DAF7FB'u, lo: 0xDC33745EC97BE906'u),
  489. uint64x2(hi: 0x86F0AC99B4E8DAFD'u, lo: 0x69A028BB3DED71A3'u),
  490. uint64x2(hi: 0xA8ACD7C0222311BC'u, lo: 0xC40832EA0D68CE0C'u),
  491. uint64x2(hi: 0xD2D80DB02AABD62B'u, lo: 0xF50A3FA490C30190'u),
  492. uint64x2(hi: 0x83C7088E1AAB65DB'u, lo: 0x792667C6DA79E0FA'u),
  493. uint64x2(hi: 0xA4B8CAB1A1563F52'u, lo: 0x577001B891185938'u),
  494. uint64x2(hi: 0xCDE6FD5E09ABCF26'u, lo: 0xED4C0226B55E6F86'u),
  495. uint64x2(hi: 0x80B05E5AC60B6178'u, lo: 0x544F8158315B05B4'u),
  496. uint64x2(hi: 0xA0DC75F1778E39D6'u, lo: 0x696361AE3DB1C721'u),
  497. uint64x2(hi: 0xC913936DD571C84C'u, lo: 0x03BC3A19CD1E38E9'u),
  498. uint64x2(hi: 0xFB5878494ACE3A5F'u, lo: 0x04AB48A04065C723'u),
  499. uint64x2(hi: 0x9D174B2DCEC0E47B'u, lo: 0x62EB0D64283F9C76'u),
  500. uint64x2(hi: 0xC45D1DF942711D9A'u, lo: 0x3BA5D0BD324F8394'u),
  501. uint64x2(hi: 0xF5746577930D6500'u, lo: 0xCA8F44EC7EE36479'u),
  502. uint64x2(hi: 0x9968BF6ABBE85F20'u, lo: 0x7E998B13CF4E1ECB'u),
  503. uint64x2(hi: 0xBFC2EF456AE276E8'u, lo: 0x9E3FEDD8C321A67E'u),
  504. uint64x2(hi: 0xEFB3AB16C59B14A2'u, lo: 0xC5CFE94EF3EA101E'u),
  505. uint64x2(hi: 0x95D04AEE3B80ECE5'u, lo: 0xBBA1F1D158724A12'u),
  506. uint64x2(hi: 0xBB445DA9CA61281F'u, lo: 0x2A8A6E45AE8EDC97'u),
  507. uint64x2(hi: 0xEA1575143CF97226'u, lo: 0xF52D09D71A3293BD'u),
  508. uint64x2(hi: 0x924D692CA61BE758'u, lo: 0x593C2626705F9C56'u),
  509. uint64x2(hi: 0xB6E0C377CFA2E12E'u, lo: 0x6F8B2FB00C77836C'u),
  510. uint64x2(hi: 0xE498F455C38B997A'u, lo: 0x0B6DFB9C0F956447'u),
  511. uint64x2(hi: 0x8EDF98B59A373FEC'u, lo: 0x4724BD4189BD5EAC'u),
  512. uint64x2(hi: 0xB2977EE300C50FE7'u, lo: 0x58EDEC91EC2CB657'u),
  513. uint64x2(hi: 0xDF3D5E9BC0F653E1'u, lo: 0x2F2967B66737E3ED'u),
  514. uint64x2(hi: 0x8B865B215899F46C'u, lo: 0xBD79E0D20082EE74'u),
  515. uint64x2(hi: 0xAE67F1E9AEC07187'u, lo: 0xECD8590680A3AA11'u),
  516. uint64x2(hi: 0xDA01EE641A708DE9'u, lo: 0xE80E6F4820CC9495'u),
  517. uint64x2(hi: 0x884134FE908658B2'u, lo: 0x3109058D147FDCDD'u),
  518. uint64x2(hi: 0xAA51823E34A7EEDE'u, lo: 0xBD4B46F0599FD415'u),
  519. uint64x2(hi: 0xD4E5E2CDC1D1EA96'u, lo: 0x6C9E18AC7007C91A'u),
  520. uint64x2(hi: 0x850FADC09923329E'u, lo: 0x03E2CF6BC604DDB0'u),
  521. uint64x2(hi: 0xA6539930BF6BFF45'u, lo: 0x84DB8346B786151C'u),
  522. uint64x2(hi: 0xCFE87F7CEF46FF16'u, lo: 0xE612641865679A63'u),
  523. uint64x2(hi: 0x81F14FAE158C5F6E'u, lo: 0x4FCB7E8F3F60C07E'u),
  524. uint64x2(hi: 0xA26DA3999AEF7749'u, lo: 0xE3BE5E330F38F09D'u),
  525. uint64x2(hi: 0xCB090C8001AB551C'u, lo: 0x5CADF5BFD3072CC5'u),
  526. uint64x2(hi: 0xFDCB4FA002162A63'u, lo: 0x73D9732FC7C8F7F6'u),
  527. uint64x2(hi: 0x9E9F11C4014DDA7E'u, lo: 0x2867E7FDDCDD9AFA'u),
  528. uint64x2(hi: 0xC646D63501A1511D'u, lo: 0xB281E1FD541501B8'u),
  529. uint64x2(hi: 0xF7D88BC24209A565'u, lo: 0x1F225A7CA91A4226'u),
  530. uint64x2(hi: 0x9AE757596946075F'u, lo: 0x3375788DE9B06958'u),
  531. uint64x2(hi: 0xC1A12D2FC3978937'u, lo: 0x0052D6B1641C83AE'u),
  532. uint64x2(hi: 0xF209787BB47D6B84'u, lo: 0xC0678C5DBD23A49A'u),
  533. uint64x2(hi: 0x9745EB4D50CE6332'u, lo: 0xF840B7BA963646E0'u),
  534. uint64x2(hi: 0xBD176620A501FBFF'u, lo: 0xB650E5A93BC3D898'u),
  535. uint64x2(hi: 0xEC5D3FA8CE427AFF'u, lo: 0xA3E51F138AB4CEBE'u),
  536. uint64x2(hi: 0x93BA47C980E98CDF'u, lo: 0xC66F336C36B10137'u),
  537. uint64x2(hi: 0xB8A8D9BBE123F017'u, lo: 0xB80B0047445D4184'u),
  538. uint64x2(hi: 0xE6D3102AD96CEC1D'u, lo: 0xA60DC059157491E5'u),
  539. uint64x2(hi: 0x9043EA1AC7E41392'u, lo: 0x87C89837AD68DB2F'u),
  540. uint64x2(hi: 0xB454E4A179DD1877'u, lo: 0x29BABE4598C311FB'u),
  541. uint64x2(hi: 0xE16A1DC9D8545E94'u, lo: 0xF4296DD6FEF3D67A'u),
  542. uint64x2(hi: 0x8CE2529E2734BB1D'u, lo: 0x1899E4A65F58660C'u),
  543. uint64x2(hi: 0xB01AE745B101E9E4'u, lo: 0x5EC05DCFF72E7F8F'u),
  544. uint64x2(hi: 0xDC21A1171D42645D'u, lo: 0x76707543F4FA1F73'u),
  545. uint64x2(hi: 0x899504AE72497EBA'u, lo: 0x6A06494A791C53A8'u),
  546. uint64x2(hi: 0xABFA45DA0EDBDE69'u, lo: 0x0487DB9D17636892'u),
  547. uint64x2(hi: 0xD6F8D7509292D603'u, lo: 0x45A9D2845D3C42B6'u),
  548. uint64x2(hi: 0x865B86925B9BC5C2'u, lo: 0x0B8A2392BA45A9B2'u),
  549. uint64x2(hi: 0xA7F26836F282B732'u, lo: 0x8E6CAC7768D7141E'u),
  550. uint64x2(hi: 0xD1EF0244AF2364FF'u, lo: 0x3207D795430CD926'u),
  551. uint64x2(hi: 0x8335616AED761F1F'u, lo: 0x7F44E6BD49E807B8'u),
  552. uint64x2(hi: 0xA402B9C5A8D3A6E7'u, lo: 0x5F16206C9C6209A6'u),
  553. uint64x2(hi: 0xCD036837130890A1'u, lo: 0x36DBA887C37A8C0F'u),
  554. uint64x2(hi: 0x802221226BE55A64'u, lo: 0xC2494954DA2C9789'u),
  555. uint64x2(hi: 0xA02AA96B06DEB0FD'u, lo: 0xF2DB9BAA10B7BD6C'u),
  556. uint64x2(hi: 0xC83553C5C8965D3D'u, lo: 0x6F92829494E5ACC7'u),
  557. uint64x2(hi: 0xFA42A8B73ABBF48C'u, lo: 0xCB772339BA1F17F9'u),
  558. uint64x2(hi: 0x9C69A97284B578D7'u, lo: 0xFF2A760414536EFB'u),
  559. uint64x2(hi: 0xC38413CF25E2D70D'u, lo: 0xFEF5138519684ABA'u),
  560. uint64x2(hi: 0xF46518C2EF5B8CD1'u, lo: 0x7EB258665FC25D69'u),
  561. uint64x2(hi: 0x98BF2F79D5993802'u, lo: 0xEF2F773FFBD97A61'u),
  562. uint64x2(hi: 0xBEEEFB584AFF8603'u, lo: 0xAAFB550FFACFD8FA'u),
  563. uint64x2(hi: 0xEEAABA2E5DBF6784'u, lo: 0x95BA2A53F983CF38'u),
  564. uint64x2(hi: 0x952AB45CFA97A0B2'u, lo: 0xDD945A747BF26183'u),
  565. uint64x2(hi: 0xBA756174393D88DF'u, lo: 0x94F971119AEEF9E4'u),
  566. uint64x2(hi: 0xE912B9D1478CEB17'u, lo: 0x7A37CD5601AAB85D'u),
  567. uint64x2(hi: 0x91ABB422CCB812EE'u, lo: 0xAC62E055C10AB33A'u),
  568. uint64x2(hi: 0xB616A12B7FE617AA'u, lo: 0x577B986B314D6009'u),
  569. uint64x2(hi: 0xE39C49765FDF9D94'u, lo: 0xED5A7E85FDA0B80B'u),
  570. uint64x2(hi: 0x8E41ADE9FBEBC27D'u, lo: 0x14588F13BE847307'u),
  571. uint64x2(hi: 0xB1D219647AE6B31C'u, lo: 0x596EB2D8AE258FC8'u),
  572. uint64x2(hi: 0xDE469FBD99A05FE3'u, lo: 0x6FCA5F8ED9AEF3BB'u),
  573. uint64x2(hi: 0x8AEC23D680043BEE'u, lo: 0x25DE7BB9480D5854'u),
  574. uint64x2(hi: 0xADA72CCC20054AE9'u, lo: 0xAF561AA79A10AE6A'u),
  575. uint64x2(hi: 0xD910F7FF28069DA4'u, lo: 0x1B2BA1518094DA04'u),
  576. uint64x2(hi: 0x87AA9AFF79042286'u, lo: 0x90FB44D2F05D0842'u),
  577. uint64x2(hi: 0xA99541BF57452B28'u, lo: 0x353A1607AC744A53'u),
  578. uint64x2(hi: 0xD3FA922F2D1675F2'u, lo: 0x42889B8997915CE8'u),
  579. uint64x2(hi: 0x847C9B5D7C2E09B7'u, lo: 0x69956135FEBADA11'u),
  580. uint64x2(hi: 0xA59BC234DB398C25'u, lo: 0x43FAB9837E699095'u),
  581. uint64x2(hi: 0xCF02B2C21207EF2E'u, lo: 0x94F967E45E03F4BB'u),
  582. uint64x2(hi: 0x8161AFB94B44F57D'u, lo: 0x1D1BE0EEBAC278F5'u),
  583. uint64x2(hi: 0xA1BA1BA79E1632DC'u, lo: 0x6462D92A69731732'u),
  584. uint64x2(hi: 0xCA28A291859BBF93'u, lo: 0x7D7B8F7503CFDCFE'u),
  585. uint64x2(hi: 0xFCB2CB35E702AF78'u, lo: 0x5CDA735244C3D43E'u),
  586. uint64x2(hi: 0x9DEFBF01B061ADAB'u, lo: 0x3A0888136AFA64A7'u),
  587. uint64x2(hi: 0xC56BAEC21C7A1916'u, lo: 0x088AAA1845B8FDD0'u),
  588. uint64x2(hi: 0xF6C69A72A3989F5B'u, lo: 0x8AAD549E57273D45'u),
  589. uint64x2(hi: 0x9A3C2087A63F6399'u, lo: 0x36AC54E2F678864B'u),
  590. uint64x2(hi: 0xC0CB28A98FCF3C7F'u, lo: 0x84576A1BB416A7DD'u),
  591. uint64x2(hi: 0xF0FDF2D3F3C30B9F'u, lo: 0x656D44A2A11C51D5'u),
  592. uint64x2(hi: 0x969EB7C47859E743'u, lo: 0x9F644AE5A4B1B325'u),
  593. uint64x2(hi: 0xBC4665B596706114'u, lo: 0x873D5D9F0DDE1FEE'u),
  594. uint64x2(hi: 0xEB57FF22FC0C7959'u, lo: 0xA90CB506D155A7EA'u),
  595. uint64x2(hi: 0x9316FF75DD87CBD8'u, lo: 0x09A7F12442D588F2'u),
  596. uint64x2(hi: 0xB7DCBF5354E9BECE'u, lo: 0x0C11ED6D538AEB2F'u),
  597. uint64x2(hi: 0xE5D3EF282A242E81'u, lo: 0x8F1668C8A86DA5FA'u),
  598. uint64x2(hi: 0x8FA475791A569D10'u, lo: 0xF96E017D694487BC'u),
  599. uint64x2(hi: 0xB38D92D760EC4455'u, lo: 0x37C981DCC395A9AC'u),
  600. uint64x2(hi: 0xE070F78D3927556A'u, lo: 0x85BBE253F47B1417'u),
  601. uint64x2(hi: 0x8C469AB843B89562'u, lo: 0x93956D7478CCEC8E'u),
  602. uint64x2(hi: 0xAF58416654A6BABB'u, lo: 0x387AC8D1970027B2'u),
  603. uint64x2(hi: 0xDB2E51BFE9D0696A'u, lo: 0x06997B05FCC0319E'u),
  604. uint64x2(hi: 0x88FCF317F22241E2'u, lo: 0x441FECE3BDF81F03'u),
  605. uint64x2(hi: 0xAB3C2FDDEEAAD25A'u, lo: 0xD527E81CAD7626C3'u),
  606. uint64x2(hi: 0xD60B3BD56A5586F1'u, lo: 0x8A71E223D8D3B074'u),
  607. uint64x2(hi: 0x85C7056562757456'u, lo: 0xF6872D5667844E49'u),
  608. uint64x2(hi: 0xA738C6BEBB12D16C'u, lo: 0xB428F8AC016561DB'u),
  609. uint64x2(hi: 0xD106F86E69D785C7'u, lo: 0xE13336D701BEBA52'u),
  610. uint64x2(hi: 0x82A45B450226B39C'u, lo: 0xECC0024661173473'u),
  611. uint64x2(hi: 0xA34D721642B06084'u, lo: 0x27F002D7F95D0190'u),
  612. uint64x2(hi: 0xCC20CE9BD35C78A5'u, lo: 0x31EC038DF7B441F4'u),
  613. uint64x2(hi: 0xFF290242C83396CE'u, lo: 0x7E67047175A15271'u),
  614. uint64x2(hi: 0x9F79A169BD203E41'u, lo: 0x0F0062C6E984D386'u),
  615. uint64x2(hi: 0xC75809C42C684DD1'u, lo: 0x52C07B78A3E60868'u),
  616. uint64x2(hi: 0xF92E0C3537826145'u, lo: 0xA7709A56CCDF8A82'u),
  617. uint64x2(hi: 0x9BBCC7A142B17CCB'u, lo: 0x88A66076400BB691'u),
  618. uint64x2(hi: 0xC2ABF989935DDBFE'u, lo: 0x6ACFF893D00EA435'u),
  619. uint64x2(hi: 0xF356F7EBF83552FE'u, lo: 0x0583F6B8C4124D43'u),
  620. uint64x2(hi: 0x98165AF37B2153DE'u, lo: 0xC3727A337A8B704A'u),
  621. uint64x2(hi: 0xBE1BF1B059E9A8D6'u, lo: 0x744F18C0592E4C5C'u),
  622. uint64x2(hi: 0xEDA2EE1C7064130C'u, lo: 0x1162DEF06F79DF73'u),
  623. uint64x2(hi: 0x9485D4D1C63E8BE7'u, lo: 0x8ADDCB5645AC2BA8'u),
  624. uint64x2(hi: 0xB9A74A0637CE2EE1'u, lo: 0x6D953E2BD7173692'u),
  625. uint64x2(hi: 0xE8111C87C5C1BA99'u, lo: 0xC8FA8DB6CCDD0437'u),
  626. uint64x2(hi: 0x910AB1D4DB9914A0'u, lo: 0x1D9C9892400A22A2'u),
  627. uint64x2(hi: 0xB54D5E4A127F59C8'u, lo: 0x2503BEB6D00CAB4B'u),
  628. uint64x2(hi: 0xE2A0B5DC971F303A'u, lo: 0x2E44AE64840FD61D'u),
  629. uint64x2(hi: 0x8DA471A9DE737E24'u, lo: 0x5CEAECFED289E5D2'u),
  630. uint64x2(hi: 0xB10D8E1456105DAD'u, lo: 0x7425A83E872C5F47'u),
  631. uint64x2(hi: 0xDD50F1996B947518'u, lo: 0xD12F124E28F77719'u),
  632. uint64x2(hi: 0x8A5296FFE33CC92F'u, lo: 0x82BD6B70D99AAA6F'u),
  633. uint64x2(hi: 0xACE73CBFDC0BFB7B'u, lo: 0x636CC64D1001550B'u),
  634. uint64x2(hi: 0xD8210BEFD30EFA5A'u, lo: 0x3C47F7E05401AA4E'u),
  635. uint64x2(hi: 0x8714A775E3E95C78'u, lo: 0x65ACFAEC34810A71'u),
  636. uint64x2(hi: 0xA8D9D1535CE3B396'u, lo: 0x7F1839A741A14D0D'u),
  637. uint64x2(hi: 0xD31045A8341CA07C'u, lo: 0x1EDE48111209A050'u),
  638. uint64x2(hi: 0x83EA2B892091E44D'u, lo: 0x934AED0AAB460432'u),
  639. uint64x2(hi: 0xA4E4B66B68B65D60'u, lo: 0xF81DA84D5617853F'u),
  640. uint64x2(hi: 0xCE1DE40642E3F4B9'u, lo: 0x36251260AB9D668E'u),
  641. uint64x2(hi: 0x80D2AE83E9CE78F3'u, lo: 0xC1D72B7C6B426019'u),
  642. uint64x2(hi: 0xA1075A24E4421730'u, lo: 0xB24CF65B8612F81F'u),
  643. uint64x2(hi: 0xC94930AE1D529CFC'u, lo: 0xDEE033F26797B627'u),
  644. uint64x2(hi: 0xFB9B7CD9A4A7443C'u, lo: 0x169840EF017DA3B1'u),
  645. uint64x2(hi: 0x9D412E0806E88AA5'u, lo: 0x8E1F289560EE864E'u),
  646. uint64x2(hi: 0xC491798A08A2AD4E'u, lo: 0xF1A6F2BAB92A27E2'u),
  647. uint64x2(hi: 0xF5B5D7EC8ACB58A2'u, lo: 0xAE10AF696774B1DB'u),
  648. uint64x2(hi: 0x9991A6F3D6BF1765'u, lo: 0xACCA6DA1E0A8EF29'u),
  649. uint64x2(hi: 0xBFF610B0CC6EDD3F'u, lo: 0x17FD090A58D32AF3'u),
  650. uint64x2(hi: 0xEFF394DCFF8A948E'u, lo: 0xDDFC4B4CEF07F5B0'u),
  651. uint64x2(hi: 0x95F83D0A1FB69CD9'u, lo: 0x4ABDAF101564F98E'u),
  652. uint64x2(hi: 0xBB764C4CA7A4440F'u, lo: 0x9D6D1AD41ABE37F1'u),
  653. uint64x2(hi: 0xEA53DF5FD18D5513'u, lo: 0x84C86189216DC5ED'u),
  654. uint64x2(hi: 0x92746B9BE2F8552C'u, lo: 0x32FD3CF5B4E49BB4'u),
  655. uint64x2(hi: 0xB7118682DBB66A77'u, lo: 0x3FBC8C33221DC2A1'u),
  656. uint64x2(hi: 0xE4D5E82392A40515'u, lo: 0x0FABAF3FEAA5334A'u),
  657. uint64x2(hi: 0x8F05B1163BA6832D'u, lo: 0x29CB4D87F2A7400E'u),
  658. uint64x2(hi: 0xB2C71D5BCA9023F8'u, lo: 0x743E20E9EF511012'u),
  659. uint64x2(hi: 0xDF78E4B2BD342CF6'u, lo: 0x914DA9246B255416'u),
  660. uint64x2(hi: 0x8BAB8EEFB6409C1A'u, lo: 0x1AD089B6C2F7548E'u),
  661. uint64x2(hi: 0xAE9672ABA3D0C320'u, lo: 0xA184AC2473B529B1'u),
  662. uint64x2(hi: 0xDA3C0F568CC4F3E8'u, lo: 0xC9E5D72D90A2741E'u),
  663. uint64x2(hi: 0x8865899617FB1871'u, lo: 0x7E2FA67C7A658892'u),
  664. uint64x2(hi: 0xAA7EEBFB9DF9DE8D'u, lo: 0xDDBB901B98FEEAB7'u),
  665. uint64x2(hi: 0xD51EA6FA85785631'u, lo: 0x552A74227F3EA565'u),
  666. uint64x2(hi: 0x8533285C936B35DE'u, lo: 0xD53A88958F87275F'u),
  667. uint64x2(hi: 0xA67FF273B8460356'u, lo: 0x8A892ABAF368F137'u),
  668. uint64x2(hi: 0xD01FEF10A657842C'u, lo: 0x2D2B7569B0432D85'u),
  669. uint64x2(hi: 0x8213F56A67F6B29B'u, lo: 0x9C3B29620E29FC73'u),
  670. uint64x2(hi: 0xA298F2C501F45F42'u, lo: 0x8349F3BA91B47B8F'u),
  671. uint64x2(hi: 0xCB3F2F7642717713'u, lo: 0x241C70A936219A73'u),
  672. uint64x2(hi: 0xFE0EFB53D30DD4D7'u, lo: 0xED238CD383AA0110'u),
  673. uint64x2(hi: 0x9EC95D1463E8A506'u, lo: 0xF4363804324A40AA'u),
  674. uint64x2(hi: 0xC67BB4597CE2CE48'u, lo: 0xB143C6053EDCD0D5'u),
  675. uint64x2(hi: 0xF81AA16FDC1B81DA'u, lo: 0xDD94B7868E94050A'u),
  676. uint64x2(hi: 0x9B10A4E5E9913128'u, lo: 0xCA7CF2B4191C8326'u),
  677. uint64x2(hi: 0xC1D4CE1F63F57D72'u, lo: 0xFD1C2F611F63A3F0'u),
  678. uint64x2(hi: 0xF24A01A73CF2DCCF'u, lo: 0xBC633B39673C8CEC'u),
  679. uint64x2(hi: 0x976E41088617CA01'u, lo: 0xD5BE0503E085D813'u),
  680. uint64x2(hi: 0xBD49D14AA79DBC82'u, lo: 0x4B2D8644D8A74E18'u),
  681. uint64x2(hi: 0xEC9C459D51852BA2'u, lo: 0xDDF8E7D60ED1219E'u),
  682. uint64x2(hi: 0x93E1AB8252F33B45'u, lo: 0xCABB90E5C942B503'u),
  683. uint64x2(hi: 0xB8DA1662E7B00A17'u, lo: 0x3D6A751F3B936243'u),
  684. uint64x2(hi: 0xE7109BFBA19C0C9D'u, lo: 0x0CC512670A783AD4'u),
  685. uint64x2(hi: 0x906A617D450187E2'u, lo: 0x27FB2B80668B24C5'u),
  686. uint64x2(hi: 0xB484F9DC9641E9DA'u, lo: 0xB1F9F660802DEDF6'u),
  687. uint64x2(hi: 0xE1A63853BBD26451'u, lo: 0x5E7873F8A0396973'u),
  688. uint64x2(hi: 0x8D07E33455637EB2'u, lo: 0xDB0B487B6423E1E8'u),
  689. uint64x2(hi: 0xB049DC016ABC5E5F'u, lo: 0x91CE1A9A3D2CDA62'u),
  690. uint64x2(hi: 0xDC5C5301C56B75F7'u, lo: 0x7641A140CC7810FB'u),
  691. uint64x2(hi: 0x89B9B3E11B6329BA'u, lo: 0xA9E904C87FCB0A9D'u),
  692. uint64x2(hi: 0xAC2820D9623BF429'u, lo: 0x546345FA9FBDCD44'u),
  693. uint64x2(hi: 0xD732290FBACAF133'u, lo: 0xA97C177947AD4095'u),
  694. uint64x2(hi: 0x867F59A9D4BED6C0'u, lo: 0x49ED8EABCCCC485D'u),
  695. uint64x2(hi: 0xA81F301449EE8C70'u, lo: 0x5C68F256BFFF5A74'u),
  696. uint64x2(hi: 0xD226FC195C6A2F8C'u, lo: 0x73832EEC6FFF3111'u),
  697. uint64x2(hi: 0x83585D8FD9C25DB7'u, lo: 0xC831FD53C5FF7EAB'u),
  698. uint64x2(hi: 0xA42E74F3D032F525'u, lo: 0xBA3E7CA8B77F5E55'u),
  699. uint64x2(hi: 0xCD3A1230C43FB26F'u, lo: 0x28CE1BD2E55F35EB'u),
  700. uint64x2(hi: 0x80444B5E7AA7CF85'u, lo: 0x7980D163CF5B81B3'u),
  701. uint64x2(hi: 0xA0555E361951C366'u, lo: 0xD7E105BCC332621F'u),
  702. uint64x2(hi: 0xC86AB5C39FA63440'u, lo: 0x8DD9472BF3FEFAA7'u),
  703. uint64x2(hi: 0xFA856334878FC150'u, lo: 0xB14F98F6F0FEB951'u),
  704. uint64x2(hi: 0x9C935E00D4B9D8D2'u, lo: 0x6ED1BF9A569F33D3'u),
  705. uint64x2(hi: 0xC3B8358109E84F07'u, lo: 0x0A862F80EC4700C8'u),
  706. uint64x2(hi: 0xF4A642E14C6262C8'u, lo: 0xCD27BB612758C0FA'u),
  707. uint64x2(hi: 0x98E7E9CCCFBD7DBD'u, lo: 0x8038D51CB897789C'u),
  708. uint64x2(hi: 0xBF21E44003ACDD2C'u, lo: 0xE0470A63E6BD56C3'u),
  709. uint64x2(hi: 0xEEEA5D5004981478'u, lo: 0x1858CCFCE06CAC74'u),
  710. uint64x2(hi: 0x95527A5202DF0CCB'u, lo: 0x0F37801E0C43EBC8'u),
  711. uint64x2(hi: 0xBAA718E68396CFFD'u, lo: 0xD30560258F54E6BA'u),
  712. uint64x2(hi: 0xE950DF20247C83FD'u, lo: 0x47C6B82EF32A2069'u),
  713. uint64x2(hi: 0x91D28B7416CDD27E'u, lo: 0x4CDC331D57FA5441'u),
  714. uint64x2(hi: 0xB6472E511C81471D'u, lo: 0xE0133FE4ADF8E952'u),
  715. uint64x2(hi: 0xE3D8F9E563A198E5'u, lo: 0x58180FDDD97723A6'u),
  716. uint64x2(hi: 0x8E679C2F5E44FF8F'u, lo: 0x570F09EAA7EA7648'u),
  717. uint64x2(hi: 0xB201833B35D63F73'u, lo: 0x2CD2CC6551E513DA'u),
  718. uint64x2(hi: 0xDE81E40A034BCF4F'u, lo: 0xF8077F7EA65E58D1'u),
  719. uint64x2(hi: 0x8B112E86420F6191'u, lo: 0xFB04AFAF27FAF782'u),
  720. uint64x2(hi: 0xADD57A27D29339F6'u, lo: 0x79C5DB9AF1F9B563'u),
  721. uint64x2(hi: 0xD94AD8B1C7380874'u, lo: 0x18375281AE7822BC'u),
  722. uint64x2(hi: 0x87CEC76F1C830548'u, lo: 0x8F2293910D0B15B5'u),
  723. uint64x2(hi: 0xA9C2794AE3A3C69A'u, lo: 0xB2EB3875504DDB22'u),
  724. uint64x2(hi: 0xD433179D9C8CB841'u, lo: 0x5FA60692A46151EB'u),
  725. uint64x2(hi: 0x849FEEC281D7F328'u, lo: 0xDBC7C41BA6BCD333'u),
  726. uint64x2(hi: 0xA5C7EA73224DEFF3'u, lo: 0x12B9B522906C0800'u),
  727. uint64x2(hi: 0xCF39E50FEAE16BEF'u, lo: 0xD768226B34870A00'u),
  728. uint64x2(hi: 0x81842F29F2CCE375'u, lo: 0xE6A1158300D46640'u),
  729. uint64x2(hi: 0xA1E53AF46F801C53'u, lo: 0x60495AE3C1097FD0'u),
  730. uint64x2(hi: 0xCA5E89B18B602368'u, lo: 0x385BB19CB14BDFC4'u),
  731. uint64x2(hi: 0xFCF62C1DEE382C42'u, lo: 0x46729E03DD9ED7B5'u),
  732. uint64x2(hi: 0x9E19DB92B4E31BA9'u, lo: 0x6C07A2C26A8346D1'u),
  733. uint64x2(hi: 0xC5A05277621BE293'u, lo: 0xC7098B7305241885'u),
  734. uint64x2(hi: 0xF70867153AA2DB38'u, lo: 0xB8CBEE4FC66D1EA7'u)]
  735. dragonbox_Assert(k >= kMin)
  736. dragonbox_Assert(k <= kMax)
  737. return pow10[k - kMin]
  738. ## Returns whether value is divisible by 2^e2
  739. proc multipleOfPow2*(value: uint64; e2: int32): bool {.inline.} =
  740. dragonbox_Assert(e2 >= 0)
  741. return e2 < 64 and (value and ((uint64(1) shl e2) - 1)) == 0
  742. ## Returns whether value is divisible by 5^e5
  743. proc multipleOfPow5*(value: uint64; e5: int32): bool {.inline.} =
  744. type
  745. MulCmp {.bycopy.} = object
  746. mul: uint64
  747. cmp: uint64
  748. const
  749. mod5 = [MulCmp(mul: 0x0000000000000001'u, cmp: 0xFFFFFFFFFFFFFFFF'u),
  750. MulCmp(mul: 0xCCCCCCCCCCCCCCCD'u, cmp: 0x3333333333333333'u),
  751. MulCmp(mul: 0x8F5C28F5C28F5C29'u, cmp: 0x0A3D70A3D70A3D70'u),
  752. MulCmp(mul: 0x1CAC083126E978D5'u, cmp: 0x020C49BA5E353F7C'u),
  753. MulCmp(mul: 0xD288CE703AFB7E91'u, cmp: 0x0068DB8BAC710CB2'u),
  754. MulCmp(mul: 0x5D4E8FB00BCBE61D'u, cmp: 0x0014F8B588E368F0'u),
  755. MulCmp(mul: 0x790FB65668C26139'u, cmp: 0x000431BDE82D7B63'u),
  756. MulCmp(mul: 0xE5032477AE8D46A5'u, cmp: 0x0000D6BF94D5E57A'u),
  757. MulCmp(mul: 0xC767074B22E90E21'u, cmp: 0x00002AF31DC46118'u),
  758. MulCmp(mul: 0x8E47CE423A2E9C6D'u, cmp: 0x0000089705F4136B'u),
  759. MulCmp(mul: 0x4FA7F60D3ED61F49'u, cmp: 0x000001B7CDFD9D7B'u),
  760. MulCmp(mul: 0x0FEE64690C913975'u, cmp: 0x00000057F5FF85E5'u),
  761. MulCmp(mul: 0x3662E0E1CF503EB1'u, cmp: 0x000000119799812D'u),
  762. MulCmp(mul: 0xA47A2CF9F6433FBD'u, cmp: 0x0000000384B84D09'u),
  763. MulCmp(mul: 0x54186F653140A659'u, cmp: 0x00000000B424DC35'u),
  764. MulCmp(mul: 0x7738164770402145'u, cmp: 0x0000000024075F3D'u),
  765. MulCmp(mul: 0xE4A4D1417CD9A041'u, cmp: 0x000000000734ACA5'u),
  766. MulCmp(mul: 0xC75429D9E5C5200D'u, cmp: 0x000000000170EF54'u),
  767. MulCmp(mul: 0xC1773B91FAC10669'u, cmp: 0x000000000049C977'u),
  768. MulCmp(mul: 0x26B172506559CE15'u, cmp: 0x00000000000EC1E4'u),
  769. MulCmp(mul: 0xD489E3A9ADDEC2D1'u, cmp: 0x000000000002F394'u),
  770. MulCmp(mul: 0x90E860BB892C8D5D'u, cmp: 0x000000000000971D'u),
  771. MulCmp(mul: 0x502E79BF1B6F4F79'u, cmp: 0x0000000000001E39'u),
  772. MulCmp(mul: 0xDCD618596BE30FE5'u, cmp: 0x000000000000060B'u),
  773. MulCmp(mul: 0x2C2AD1AB7BFA3661'u, cmp: 0x0000000000000135'u)]
  774. dragonbox_Assert(e5 >= 0)
  775. dragonbox_Assert(e5 <= 24)
  776. let m5: MulCmp = mod5[e5]
  777. return value * m5.mul <= m5.cmp
  778. type
  779. FloatingDecimal64* {.bycopy.} = object
  780. significand*: uint64
  781. exponent*: int32
  782. proc toDecimal64AsymmetricInterval*(e2: int32): FloatingDecimal64 {.inline.} =
  783. ## NB:
  784. ## accept_lower_endpoint = true
  785. ## accept_upper_endpoint = true
  786. const
  787. P: int32 = significandSize
  788. ## Compute k and beta
  789. let minusK: int32 = floorLog10ThreeQuartersPow2(e2)
  790. let betaMinus1: int32 = e2 + floorLog2Pow10(-minusK)
  791. ## Compute xi and zi
  792. let pow10: uint64x2 = computePow10(-minusK)
  793. let lowerEndpoint: uint64 = (pow10.hi - (pow10.hi shr (P + 1))) shr
  794. (64 - P - betaMinus1)
  795. let upperEndpoint: uint64 = (pow10.hi + (pow10.hi shr (P + 0))) shr
  796. (64 - P - betaMinus1)
  797. ## If we don't accept the left endpoint (but we do!) or
  798. ## if the left endpoint is not an integer, increase it
  799. let lowerEndpointIsInteger: bool = (2 <= e2 and e2 <= 3)
  800. let xi: uint64 = lowerEndpoint + uint64(not lowerEndpointIsInteger)
  801. let zi: uint64 = upperEndpoint
  802. ## Try bigger divisor
  803. var q: uint64 = zi div 10
  804. if q * 10 >= xi:
  805. return FloatingDecimal64(significand: q, exponent: minusK + 1)
  806. q = ((pow10.hi shr (64 - (P + 1) - betaMinus1)) + 1) div 2
  807. ## When tie occurs, choose one of them according to the rule
  808. if e2 == -77:
  809. dec(q, ord(q mod 2 != 0))
  810. ## Round to even.
  811. else:
  812. inc(q, ord(q < xi))
  813. return FloatingDecimal64(significand: q, exponent: minusK)
  814. proc computeDelta*(pow10: uint64x2; betaMinus1: int32): uint32 {.inline.} =
  815. dragonbox_Assert(betaMinus1 >= 0)
  816. dragonbox_Assert(betaMinus1 <= 63)
  817. return cast[uint32](pow10.hi shr (64 - 1 - betaMinus1))
  818. when defined(sizeof_Int128):
  819. proc mul128*(x: uint64; y: uint64): uint64x2 {.inline.} =
  820. ## 1 mulx
  821. type
  822. uint128T = uint128
  823. let p: uint128T = uint128T(x) * y
  824. let hi: uint64 = cast[uint64](p shr 64)
  825. let lo: uint64 = cast[uint64](p)
  826. return (hi, lo)
  827. elif defined(vcc) and defined(cpu64):
  828. proc umul128(x, y: uint64, z: ptr uint64): uint64 {.importc: "_umul128", header: "<intrin.h>".}
  829. proc mul128*(x: uint64; y: uint64): uint64x2 {.inline.} =
  830. var hi: uint64 = 0
  831. var lo: uint64 = umul128(x, y, addr(hi))
  832. return uint64x2(hi: hi, lo: lo)
  833. else:
  834. proc lo32*(x: uint64): uint32 {.inline.} =
  835. return cast[uint32](x)
  836. proc hi32*(x: uint64): uint32 {.inline.} =
  837. return cast[uint32](x shr 32)
  838. proc mul128*(a: uint64; b: uint64): uint64x2 {.inline.} =
  839. let b00: uint64 = uint64(lo32(a)) * lo32(b)
  840. let b01: uint64 = uint64(lo32(a)) * hi32(b)
  841. let b10: uint64 = uint64(hi32(a)) * lo32(b)
  842. let b11: uint64 = uint64(hi32(a)) * hi32(b)
  843. let mid1: uint64 = b10 + hi32(b00)
  844. let mid2: uint64 = b01 + lo32(mid1)
  845. let hi: uint64 = b11 + hi32(mid1) + hi32(mid2)
  846. let lo: uint64 = lo32(b00) or uint64(lo32(mid2)) shl 32
  847. return uint64x2(hi: hi, lo: lo)
  848. ## Returns (x * y) / 2^128
  849. proc mulShift*(x: uint64; y: uint64x2): uint64 {.inline.} =
  850. ## 2 mulx
  851. var p1: uint64x2 = mul128(x, y.hi)
  852. var p0: uint64x2 = mul128(x, y.lo)
  853. p1.lo += p0.hi
  854. inc(p1.hi, ord(p1.lo < p0.hi))
  855. return p1.hi
  856. proc mulParity*(twoF: uint64; pow10: uint64x2; betaMinus1: int32): bool {.inline.} =
  857. ## 1 mulx, 1 mul
  858. dragonbox_Assert(betaMinus1 >= 1)
  859. dragonbox_Assert(betaMinus1 <= 63)
  860. let p01: uint64 = twoF * pow10.hi
  861. let p10: uint64 = mul128(twoF, pow10.lo).hi
  862. let mid: uint64 = p01 + p10
  863. return (mid and (uint64(1) shl (64 - betaMinus1))) != 0
  864. proc isIntegralEndpoint*(twoF: uint64; e2: int32; minusK: int32): bool {.inline.} =
  865. if e2 < -2:
  866. return false
  867. if e2 <= 9:
  868. return true
  869. if e2 <= 86:
  870. return multipleOfPow5(twoF, minusK)
  871. return false
  872. proc isIntegralMidpoint*(twoF: uint64; e2: int32; minusK: int32): bool {.inline.} =
  873. if e2 < -4:
  874. return multipleOfPow2(twoF, minusK - e2 + 1)
  875. if e2 <= 9:
  876. return true
  877. if e2 <= 86:
  878. return multipleOfPow5(twoF, minusK)
  879. return false
  880. proc toDecimal64*(ieeeSignificand: uint64; ieeeExponent: uint64): FloatingDecimal64 {.
  881. inline.} =
  882. const
  883. kappa: int32 = 2
  884. const
  885. bigDivisor: uint32 = 1000
  886. ## 10^(kappa + 1)
  887. const
  888. smallDivisor: uint32 = 100
  889. ## 10^(kappa)
  890. ##
  891. ## Step 1:
  892. ## integer promotion & Schubfach multiplier calculation.
  893. ##
  894. var m2: uint64
  895. var e2: int32
  896. if ieeeExponent != 0:
  897. m2 = hiddenBit or ieeeSignificand
  898. e2 = cast[int32](ieeeExponent) - exponentBias
  899. if 0 <= -e2 and -e2 < significandSize and multipleOfPow2(m2, -e2):
  900. ## Small integer.
  901. return FloatingDecimal64(significand: m2 shr -e2, exponent: 0)
  902. if ieeeSignificand == 0 and ieeeExponent > 1:
  903. ## Shorter interval case; proceed like Schubfach.
  904. return toDecimal64AsymmetricInterval(e2)
  905. else:
  906. ## Subnormal case; interval is always regular.
  907. m2 = ieeeSignificand
  908. e2 = 1 - exponentBias
  909. let isEven: bool = (m2 mod 2 == 0)
  910. let acceptLower: bool = isEven
  911. let acceptUpper: bool = isEven
  912. ## Compute k and beta.
  913. let minusK: int32 = floorLog10Pow2(e2) - kappa
  914. let betaMinus1: int32 = e2 + floorLog2Pow10(-minusK)
  915. dragonbox_Assert(betaMinus1 >= 6)
  916. dragonbox_Assert(betaMinus1 <= 9)
  917. let pow10: uint64x2 = computePow10(-minusK)
  918. ## Compute delta
  919. ## 10^kappa <= delta < 10^(kappa + 1)
  920. ## 100 <= delta < 1000
  921. let delta: uint32 = computeDelta(pow10, betaMinus1)
  922. dragonbox_Assert(delta >= smallDivisor)
  923. dragonbox_Assert(delta < bigDivisor)
  924. let twoFl: uint64 = 2 * m2 - 1
  925. let twoFc: uint64 = 2 * m2
  926. let twoFr: uint64 = 2 * m2 + 1
  927. ## (54 bits)
  928. ## Compute zi
  929. ## (54 + 9 = 63 bits)
  930. let zi: uint64 = mulShift(twoFr shl betaMinus1, pow10)
  931. ## 2 mulx
  932. ##
  933. ## Step 2:
  934. ## Try larger divisor.
  935. ##
  936. var q: uint64 = zi div bigDivisor
  937. ## uint64_t q = Mul128(zi, 0x83126E978D4FDF3Cu).hi >> 9; // 1 mulx
  938. var r: uint32 = cast[uint32](zi) - bigDivisor * cast[uint32](q)
  939. ## r = zi % BigDivisor
  940. ## 0 <= r < 1000
  941. if r < delta: ## likely ~50% ?!
  942. ## (r > deltai)
  943. ## Exclude the right endpoint if necessary
  944. if r != 0 or acceptUpper or not isIntegralEndpoint(twoFr, e2, minusK):
  945. return FloatingDecimal64(significand: q, exponent: minusK + kappa + 1)
  946. dragonbox_Assert(q != 0)
  947. dec(q)
  948. r = bigDivisor
  949. elif r == delta: ## unlikely
  950. ## Compare fractional parts.
  951. ## Check conditions in the order different from the paper
  952. ## to take advantage of short-circuiting
  953. if (acceptLower and isIntegralEndpoint(twoFl, e2, minusK)) or
  954. mulParity(twoFl, pow10, betaMinus1):
  955. return FloatingDecimal64(significand: q, exponent: minusK + kappa + 1)
  956. else:
  957. discard
  958. ##
  959. ## Step 3:
  960. ## Find the significand with the smaller divisor
  961. ##
  962. q = q * 10
  963. ## 1 hmul
  964. ## 0 <= r <= 1000
  965. let dist: uint32 = r - (delta div 2) + (smallDivisor div 2)
  966. let distQ: uint32 = dist div 100
  967. ## 1 mul
  968. ## const uint32_t dist_r = dist % 100;
  969. q += distQ
  970. ## if /*likely*/ (dist_r == 0)
  971. if dist == distQ * 100:
  972. ## const bool approx_y_parity = ((dist ^ (SmallDivisor / 2)) & 1) != 0;
  973. let approxYParity: bool = (dist and 1) != 0
  974. ## Check z^(f) >= epsilon^(f)
  975. ## We have either yi == zi - epsiloni or yi == (zi - epsiloni) - 1,
  976. ## where yi == zi - epsiloni if and only if z^(f) >= epsilon^(f)
  977. ## Since there are only 2 possibilities, we only need to care about the
  978. ## parity. Also, zi and r should have the same parity since the divisor
  979. ## is an even number
  980. if mulParity(twoFc, pow10, betaMinus1) != approxYParity:
  981. dec(q)
  982. elif q mod 2 != 0 and isIntegralMidpoint(twoFc, e2, minusK):
  983. dec(q)
  984. return FloatingDecimal64(significand: q, exponent: minusK + kappa)
  985. # ==================================================================================================
  986. # ToChars
  987. # ==================================================================================================
  988. when false:
  989. template `+!`(x: cstring; offset: int): cstring = cast[cstring](cast[uint](x) + uint(offset))
  990. template dec(x: cstring; offset=1) = x = cast[cstring](cast[uint](x) - uint(offset))
  991. template inc(x: cstring; offset=1) = x = cast[cstring](cast[uint](x) + uint(offset))
  992. proc memset(x: cstring; ch: char; L: int) {.importc, nodecl.}
  993. proc memmove(a, b: cstring; L: int) {.importc, nodecl.}
  994. proc utoa8DigitsSkipTrailingZeros*(buf: var openArray[char]; pos: int; digits: uint32): int {.inline.} =
  995. dragonbox_Assert(digits >= 1)
  996. dragonbox_Assert(digits <= 99999999'u32)
  997. let q: uint32 = digits div 10000
  998. let r: uint32 = digits mod 10000
  999. let qH: uint32 = q div 100
  1000. let qL: uint32 = q mod 100
  1001. utoa2Digits(buf, pos, qH)
  1002. utoa2Digits(buf, pos + 2, qL)
  1003. if r == 0:
  1004. return trailingZeros2Digits(if qL == 0: qH else: qL) + (if qL == 0: 6 else: 4)
  1005. else:
  1006. let rH: uint32 = r div 100
  1007. let rL: uint32 = r mod 100
  1008. utoa2Digits(buf, pos + 4, rH)
  1009. utoa2Digits(buf, pos + 6, rL)
  1010. return trailingZeros2Digits(if rL == 0: rH else: rL) + (if rL == 0: 2 else: 0)
  1011. proc printDecimalDigitsBackwards*(buf: var openArray[char]; pos: int; output64: uint64): int {.inline.} =
  1012. var pos = pos
  1013. var output64 = output64
  1014. var tz = 0
  1015. ## number of trailing zeros removed.
  1016. var nd = 0
  1017. ## number of decimal digits processed.
  1018. ## At most 17 digits remaining
  1019. if output64 >= 100000000'u64:
  1020. let q: uint64 = output64 div 100000000'u64
  1021. let r: uint32 = cast[uint32](output64 mod 100000000'u64)
  1022. output64 = q
  1023. dec(pos, 8)
  1024. if r != 0:
  1025. tz = utoa8DigitsSkipTrailingZeros(buf, pos, r)
  1026. dragonbox_Assert(tz >= 0)
  1027. dragonbox_Assert(tz <= 7)
  1028. else:
  1029. tz = 8
  1030. nd = 8
  1031. dragonbox_Assert(output64 <= high(uint32))
  1032. var output = cast[uint32](output64)
  1033. if output >= 10000:
  1034. let q: uint32 = output div 10000
  1035. let r: uint32 = output mod 10000
  1036. output = q
  1037. dec(pos, 4)
  1038. if r != 0:
  1039. let rH: uint32 = r div 100
  1040. let rL: uint32 = r mod 100
  1041. utoa2Digits(buf, pos, rH)
  1042. utoa2Digits(buf, pos + 2, rL)
  1043. if tz == nd:
  1044. inc(tz, trailingZeros2Digits(if rL == 0: rH else: rL) +
  1045. (if rL == 0: 2 else: 0))
  1046. else:
  1047. if tz == nd:
  1048. inc(tz, 4)
  1049. else:
  1050. for i in 0..3: buf[pos+i] = '0'
  1051. ## (actually not required...)
  1052. inc(nd, 4)
  1053. if output >= 100:
  1054. let q: uint32 = output div 100
  1055. let r: uint32 = output mod 100
  1056. output = q
  1057. dec(pos, 2)
  1058. utoa2Digits(buf, pos, r)
  1059. if tz == nd:
  1060. inc(tz, trailingZeros2Digits(r))
  1061. inc(nd, 2)
  1062. if output >= 100:
  1063. let q2: uint32 = output div 100
  1064. let r2: uint32 = output mod 100
  1065. output = q2
  1066. dec(pos, 2)
  1067. utoa2Digits(buf, pos, r2)
  1068. if tz == nd:
  1069. inc(tz, trailingZeros2Digits(r2))
  1070. inc(nd, 2)
  1071. dragonbox_Assert(output >= 1)
  1072. dragonbox_Assert(output <= 99)
  1073. if output >= 10:
  1074. let q: uint32 = output
  1075. dec(pos, 2)
  1076. utoa2Digits(buf, pos, q)
  1077. if tz == nd:
  1078. inc(tz, trailingZeros2Digits(q))
  1079. else:
  1080. let q: uint32 = output
  1081. dragonbox_Assert(q >= 1)
  1082. dragonbox_Assert(q <= 9)
  1083. dec(pos)
  1084. buf[pos] = chr(ord('0') + q)
  1085. return tz
  1086. proc decimalLength*(v: uint64): int {.inline.} =
  1087. dragonbox_Assert(v >= 1)
  1088. dragonbox_Assert(v <= 99999999999999999'u64)
  1089. if cast[uint32](v shr 32) != 0:
  1090. if v >= 10000000000000000'u64:
  1091. return 17
  1092. if v >= 1000000000000000'u64:
  1093. return 16
  1094. if v >= 100000000000000'u64:
  1095. return 15
  1096. if v >= 10000000000000'u64:
  1097. return 14
  1098. if v >= 1000000000000'u64:
  1099. return 13
  1100. if v >= 100000000000'u64:
  1101. return 12
  1102. if v >= 10000000000'u64:
  1103. return 11
  1104. return 10
  1105. let v32: uint32 = cast[uint32](v)
  1106. if v32 >= 1000000000'u32:
  1107. return 10
  1108. if v32 >= 100000000'u32:
  1109. return 9
  1110. if v32 >= 10000000'u32:
  1111. return 8
  1112. if v32 >= 1000000'u32:
  1113. return 7
  1114. if v32 >= 100000'u32:
  1115. return 6
  1116. if v32 >= 10000'u32:
  1117. return 5
  1118. if v32 >= 1000'u32:
  1119. return 4
  1120. if v32 >= 100'u32:
  1121. return 3
  1122. if v32 >= 10'u32:
  1123. return 2
  1124. return 1
  1125. proc formatDigits*[T: Ordinal](buffer: var openArray[char]; pos: T; digits: uint64; decimalExponent: int;
  1126. forceTrailingDotZero = false): int {.inline.} =
  1127. const
  1128. minFixedDecimalPoint = -6
  1129. const
  1130. maxFixedDecimalPoint = 17
  1131. var pos:int = pos.int
  1132. assert(minFixedDecimalPoint <= -1, "internal error")
  1133. assert(maxFixedDecimalPoint >= 17, "internal error")
  1134. dragonbox_Assert(digits >= 1)
  1135. dragonbox_Assert(digits <= 99999999999999999'u64)
  1136. dragonbox_Assert(decimalExponent >= -999)
  1137. dragonbox_Assert(decimalExponent <= 999)
  1138. var numDigits = decimalLength(digits)
  1139. let decimalPoint = numDigits + decimalExponent
  1140. let useFixed: bool = minFixedDecimalPoint <= decimalPoint and
  1141. decimalPoint <= maxFixedDecimalPoint
  1142. ## Prepare the buffer.
  1143. for i in 0..<32: buffer[pos+i] = '0'
  1144. assert(minFixedDecimalPoint >= -30, "internal error")
  1145. assert(maxFixedDecimalPoint <= 32, "internal error")
  1146. var decimalDigitsPosition: int
  1147. if useFixed:
  1148. if decimalPoint <= 0:
  1149. ## 0.[000]digits
  1150. decimalDigitsPosition = 2 - decimalPoint
  1151. else:
  1152. ## dig.its
  1153. ## digits[000]
  1154. decimalDigitsPosition = 0
  1155. else:
  1156. ## dE+123 or d.igitsE+123
  1157. decimalDigitsPosition = 1
  1158. var digitsEnd = pos + int(decimalDigitsPosition + numDigits)
  1159. let tz = printDecimalDigitsBackwards(buffer, digitsEnd, digits)
  1160. dec(digitsEnd, tz)
  1161. dec(numDigits, tz)
  1162. ## decimal_exponent += tz; // => decimal_point unchanged.
  1163. if useFixed:
  1164. if decimalPoint <= 0:
  1165. ## 0.[000]digits
  1166. buffer[pos+1] = '.'
  1167. pos = digitsEnd
  1168. elif decimalPoint < numDigits:
  1169. ## dig.its
  1170. when true: #defined(vcc) and not defined(clang):
  1171. ## VC does not inline the memmove call below. (Even if compiled with /arch:AVX2.)
  1172. ## However, memcpy will be inlined.
  1173. var tmp: array[16, char]
  1174. for i in 0..<16: tmp[i] = buffer[i+pos+decimalPoint]
  1175. for i in 0..<16: buffer[i+pos+decimalPoint+1] = tmp[i]
  1176. else:
  1177. memmove(buffer +! (decimalPoint + 1), buffer +! decimalPoint, 16)
  1178. buffer[pos+decimalPoint] = '.'
  1179. pos = digitsEnd + 1
  1180. else:
  1181. ## digits[000]
  1182. inc(pos, decimalPoint)
  1183. if forceTrailingDotZero:
  1184. buffer[pos] = '.'
  1185. buffer[pos+1] = '0'
  1186. inc(pos, 2)
  1187. else:
  1188. ## Copy the first digit one place to the left.
  1189. buffer[pos] = buffer[pos+1]
  1190. if numDigits == 1:
  1191. ## dE+123
  1192. inc(pos)
  1193. else:
  1194. ## d.igitsE+123
  1195. buffer[pos+1] = '.'
  1196. pos = digitsEnd
  1197. let scientificExponent: int = decimalPoint - 1
  1198. ## SF_ASSERT(scientific_exponent != 0);
  1199. buffer[pos] = 'e'
  1200. buffer[pos+1] = if scientificExponent < 0: '-' else: '+'
  1201. inc(pos, 2)
  1202. let k: uint32 = cast[uint32](if scientificExponent < 0: -scientificExponent else: scientificExponent)
  1203. if k < 10:
  1204. buffer[pos] = chr(ord('0') + k)
  1205. inc(pos)
  1206. elif k < 100:
  1207. utoa2Digits(buffer, pos, k)
  1208. inc(pos, 2)
  1209. else:
  1210. let q: uint32 = k div 100
  1211. let r: uint32 = k mod 100
  1212. buffer[pos] = chr(ord('0') + q)
  1213. inc(pos)
  1214. utoa2Digits(buffer, pos, r)
  1215. inc(pos, 2)
  1216. return pos
  1217. proc toChars*(buffer: var openArray[char]; v: float; forceTrailingDotZero = false): int {.
  1218. inline.} =
  1219. var pos = 0
  1220. let significand: uint64 = physicalSignificand(constructDouble(v))
  1221. let exponent: uint64 = physicalExponent(constructDouble(v))
  1222. if exponent != maxIeeeExponent:
  1223. ## Finite
  1224. buffer[pos] = '-'
  1225. inc(pos, signBit(constructDouble(v)))
  1226. if exponent != 0 or significand != 0:
  1227. ## != 0
  1228. let dec = toDecimal64(significand, exponent)
  1229. return formatDigits(buffer, pos, dec.significand, dec.exponent.int,
  1230. forceTrailingDotZero)
  1231. else:
  1232. buffer[pos] = '0'
  1233. buffer[pos+1] = '.'
  1234. buffer[pos+2] = '0'
  1235. buffer[pos+3] = ' '
  1236. inc(pos, if forceTrailingDotZero: 3 else: 1)
  1237. return pos
  1238. if significand == 0:
  1239. buffer[pos] = '-'
  1240. inc(pos, signBit(constructDouble(v)))
  1241. buffer[pos] = 'i'
  1242. buffer[pos+1] = 'n'
  1243. buffer[pos+2] = 'f'
  1244. buffer[pos+3] = ' '
  1245. return pos + 3
  1246. else:
  1247. buffer[pos] = 'n'
  1248. buffer[pos+1] = 'a'
  1249. buffer[pos+2] = 'n'
  1250. buffer[pos+3] = ' '
  1251. return pos + 3
  1252. when false:
  1253. proc toString*(value: float): string =
  1254. var buffer: array[dtoaMinBufferLength, char]
  1255. let last = toChars(addr buffer, value)
  1256. let L = cast[int](last) - cast[int](addr(buffer))
  1257. result = newString(L)
  1258. copyMem(addr result[0], addr buffer[0], L)