Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/serde_json/src/lexical/cached_float80.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / serde_json / src / lexical / cached_float80.rs` 206 lines ยท 5782 bytes Raw Blame History 1 // Adapted from https://github.com/Alexhuszagh/rust-lexical. 2 3 //! Cached exponents for basen values with 80-bit extended floats. 4 //! 5 //! Exact versions of base**n as an extended-precision float, with both 6 //! large and small powers. Use the large powers to minimize the amount 7 //! of compounded error. 8 //! 9 //! These values were calculated using Python, using the arbitrary-precision 10 //! integer to calculate exact extended-representation of each value. 11 //! These values are all normalized. 12 13 use super::cached::{ExtendedFloatArray, ModeratePathPowers}; 14 15 // LOW-LEVEL 16 // --------- 17 18 // BASE10 19 20 const BASE10_SMALL_MANTISSA: [u64; 10] = [ 21 `9223372036854775808`, // 10^0 22 `11529215046068469760`, // 10^1 23 `14411518807585587200`, // 10^2 24 `18014398509481984000`, // 10^3 25 `11258999068426240000`, // 10^4 26 `14073748835532800000`, // 10^5 27 `17592186044416000000`, // 10^6 28 `10995116277760000000`, // 10^7 29 `13743895347200000000`, // 10^8 30 `17179869184000000000`, // 10^9 31 ]; 32 const BASE10_SMALL_EXPONENT: [i32; 10] = [ 33 -63, // 10^0 34 -60, // 10^1 35 -57, // 10^2 36 -54, // 10^3 37 -50, // 10^4 38 -47, // 10^5 39 -44, // 10^6 40 -40, // 10^7 41 -37, // 10^8 42 -34, // 10^9 43 ]; 44 const BASE10_LARGE_MANTISSA: [u64; 66] = [ 45 `11555125961253852697`, // 10^-350 46 `13451937075301367670`, // 10^-340 47 `15660115838168849784`, // 10^-330 48 `18230774251475056848`, // 10^-320 49 `10611707258198326947`, // 10^-310 50 `12353653155963782858`, // 10^-300 51 `14381545078898527261`, // 10^-290 52 `16742321987285426889`, // 10^-280 53 `9745314011399999080`, // 10^-270 54 `11345038669416679861`, // 10^-260 55 `13207363278391631158`, // 10^-250 56 `15375394465392026070`, // 10^-240 57 `17899314949046850752`, // 10^-230 58 `10418772551374772303`, // 10^-220 59 `12129047596099288555`, // 10^-210 60 `14120069793541087484`, // 10^-200 61 `16437924692338667210`, // 10^-190 62 `9568131466127621947`, // 10^-180 63 `11138771039116687545`, // 10^-170 64 `12967236152753102995`, // 10^-160 65 `15095849699286165408`, // 10^-150 66 `17573882009934360870`, // 10^-140 67 `10229345649675443343`, // 10^-130 68 `11908525658859223294`, // 10^-120 69 `13863348470604074297`, // 10^-110 70 `16139061738043178685`, // 10^-100 71 `9394170331095332911`, // 10^-90 72 `10936253623915059621`, // 10^-80 73 `12731474852090538039`, // 10^-70 74 `14821387422376473014`, // 10^-60 75 `17254365866976409468`, // 10^-50 76 `10043362776618689222`, // 10^-40 77 `11692013098647223345`, // 10^-30 78 `13611294676837538538`, // 10^-20 79 `15845632502852867518`, // 10^-10 80 `9223372036854775808`, // 10^0 81 `10737418240000000000`, // 10^10 82 `12500000000000000000`, // 10^20 83 `14551915228366851806`, // 10^30 84 `16940658945086006781`, // 10^40 85 `9860761315262647567`, // 10^50 86 `11479437019748901445`, // 10^60 87 `13363823550460978230`, // 10^70 88 `15557538194652854267`, // 10^80 89 `18111358157653424735`, // 10^90 90 `10542197943230523224`, // 10^100 91 `12272733663244316382`, // 10^110 92 `14287342391028437277`, // 10^120 93 `16632655625031838749`, // 10^130 94 `9681479787123295682`, // 10^140 95 `11270725851789228247`, // 10^150 96 `13120851772591970218`, // 10^160 97 `15274681817498023410`, // 10^170 98 `17782069995880619867`, // 10^180 99 `10350527006597618960`, // 10^190 100 `12049599325514420588`, // 10^200 101 `14027579833653779454`, // 10^210 102 `16330252207878254650`, // 10^220 103 `9505457831475799117`, // 10^230 104 `11065809325636130661`, // 10^240 105 `12882297539194266616`, // 10^250 106 `14996968138956309548`, // 10^260 107 `17458768723248864463`, // 10^270 108 `10162340898095201970`, // 10^280 109 `11830521861667747109`, // 10^290 110 `13772540099066387756`, // 10^300 111 ]; 112 const BASE10_LARGE_EXPONENT: [i32; 66] = [ 113 -1226, // 10^-350 114 -1193, // 10^-340 115 -1160, // 10^-330 116 -1127, // 10^-320 117 -1093, // 10^-310 118 -1060, // 10^-300 119 -1027, // 10^-290 120 -994, // 10^-280 121 -960, // 10^-270 122 -927, // 10^-260 123 -894, // 10^-250 124 -861, // 10^-240 125 -828, // 10^-230 126 -794, // 10^-220 127 -761, // 10^-210 128 -728, // 10^-200 129 -695, // 10^-190 130 -661, // 10^-180 131 -628, // 10^-170 132 -595, // 10^-160 133 -562, // 10^-150 134 -529, // 10^-140 135 -495, // 10^-130 136 -462, // 10^-120 137 -429, // 10^-110 138 -396, // 10^-100 139 -362, // 10^-90 140 -329, // 10^-80 141 -296, // 10^-70 142 -263, // 10^-60 143 -230, // 10^-50 144 -196, // 10^-40 145 -163, // 10^-30 146 -130, // 10^-20 147 -97, // 10^-10 148 -63, // 10^0 149 -30, // 10^10 150 3, // 10^20 151 36, // 10^30 152 69, // 10^40 153 103, // 10^50 154 136, // 10^60 155 169, // 10^70 156 202, // 10^80 157 235, // 10^90 158 269, // 10^100 159 302, // 10^110 160 335, // 10^120 161 368, // 10^130 162 402, // 10^140 163 435, // 10^150 164 468, // 10^160 165 501, // 10^170 166 534, // 10^180 167 568, // 10^190 168 601, // 10^200 169 634, // 10^210 170 667, // 10^220 171 701, // 10^230 172 734, // 10^240 173 767, // 10^250 174 800, // 10^260 175 833, // 10^270 176 867, // 10^280 177 900, // 10^290 178 933, // 10^300 179 ]; 180 const BASE10_SMALL_INT_POWERS: [u64; 10] = [ 181 1, 10, 100, 1000, 10000, 100000, `1000000`, `10000000`, `100000000`, `1000000000`, 182 ]; 183 const BASE10_STEP: i32 = 10; 184 const BASE10_BIAS: i32 = 350; 185 186 // HIGH LEVEL 187 // ---------- 188 189 const BASE10_POWERS: ModeratePathPowers = ModeratePathPowers { 190 small: ExtendedFloatArray { 191 mant: &BASE10_SMALL_MANTISSA, 192 exp: &BASE10_SMALL_EXPONENT, 193 }, 194 large: ExtendedFloatArray { 195 mant: &BASE10_LARGE_MANTISSA, 196 exp: &BASE10_LARGE_EXPONENT, 197 }, 198 small_int: &BASE10_SMALL_INT_POWERS, 199 step: BASE10_STEP, 200 bias: BASE10_BIAS, 201 }; 202 203 /// Get powers from base. 204 pub(crate) fn get_powers() -> &'static ModeratePathPowers { 205 &BASE10_POWERS 206 }