[{"data":1,"prerenderedAt":3163},["ShallowReactive",2],{"blog-formatting-scientific-values":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"type":11,"body":12,"_type":3156,"_id":3157,"_source":3158,"_file":3159,"_stem":3160,"_extension":3161,"sitemap":3162},"/blog/formatting-scientific-values","blog",false,"","Formatting Scientific Values in JavaScript","Scientific notation, significant figures, and SI prefixes with Intl.NumberFormat, for dashboards that show measurements.","2026-12-03","code",{"type":13,"children":14,"toc":3154},"root",[15,26,35,83,134,150,159,315,346,360,475,483,1412,1426,1434,1465,1695,1714,1722,1730,2238,2275,2283,2299,2906,2946,2954,3015,3023,3112,3120,3135,3148],{"type":16,"tag":17,"props":18,"children":19},"element","content-h1",{},[20],{"type":16,"tag":21,"props":22,"children":23},"p",{},[24],{"type":25,"value":8},"text",{"type":16,"tag":27,"props":28,"children":29},"sub-title",{},[30],{"type":16,"tag":21,"props":31,"children":32},{},[33],{"type":25,"value":34},"Scientific notation, significant figures, and SI prefixes with Intl.NumberFormat, for dashboards that show measurements",{"type":16,"tag":36,"props":37,"children":38},"paragraph",{},[39],{"type":16,"tag":21,"props":40,"children":41},{},[42,44,50,52,57,59,65,67,73,75,81],{"type":25,"value":43},"Measurement data breaks the usual number formatting. A sensor reports ",{"type":16,"tag":11,"props":45,"children":47},{"className":46},[],[48],{"type":25,"value":49},"0.0000123",{"type":25,"value":51}," and the UI shows ",{"type":16,"tag":11,"props":53,"children":55},{"className":54},[],[56],{"type":25,"value":49},{"type":25,"value":58},", or worse, ",{"type":16,"tag":11,"props":60,"children":62},{"className":61},[],[63],{"type":25,"value":64},"1.23e-5",{"type":25,"value":66}," straight from ",{"type":16,"tag":11,"props":68,"children":70},{"className":69},[],[71],{"type":25,"value":72},"String()",{"type":25,"value":74},". A large value shows up as ",{"type":16,"tag":11,"props":76,"children":78},{"className":77},[],[79],{"type":25,"value":80},"1234567.891",{"type":25,"value":82}," with more digits than the instrument can actually measure. Engineers and scientists expect values like these instead:",{"type":16,"tag":84,"props":85,"children":86},"indent",{},[87],{"type":16,"tag":88,"props":89,"children":90},"ul",{},[91,103,120],{"type":16,"tag":92,"props":93,"children":94},"li",{},[95,101],{"type":16,"tag":96,"props":97,"children":98},"strong",{},[99],{"type":25,"value":100},"4.20 × 10⁻⁴",{"type":25,"value":102}," for very small or very large values",{"type":16,"tag":92,"props":104,"children":105},{},[106,111,113,118],{"type":16,"tag":96,"props":107,"children":108},{},[109],{"type":25,"value":110},"1.20",{"type":25,"value":112},", not ",{"type":16,"tag":96,"props":114,"children":115},{},[116],{"type":25,"value":117},"1.2",{"type":25,"value":119},", when the measurement is precise to three significant figures",{"type":16,"tag":92,"props":121,"children":122},{},[123,128,129],{"type":16,"tag":96,"props":124,"children":125},{},[126],{"type":25,"value":127},"12.3 µA",{"type":25,"value":112},{"type":16,"tag":96,"props":130,"children":131},{},[132],{"type":25,"value":133},"0.0000123 A",{"type":16,"tag":36,"props":135,"children":136},{},[137],{"type":16,"tag":21,"props":138,"children":139},{},[140,142,148],{"type":25,"value":141},"All three are possible with the built-in ",{"type":16,"tag":11,"props":143,"children":145},{"className":144},[],[146],{"type":25,"value":147},"Intl.NumberFormat",{"type":25,"value":149},", plus a few small helpers. No library needed.",{"type":16,"tag":151,"props":152,"children":153},"content-h2",{},[154],{"type":16,"tag":21,"props":155,"children":156},{},[157],{"type":25,"value":158},"Scientific notation with Intl",{"type":16,"tag":160,"props":161,"children":162},"code-block",{},[163],{"type":16,"tag":164,"props":165,"children":169},"pre",{"className":166,"code":167,"language":168,"meta":7,"style":7},"language-js shiki shiki-themes github-dark","const sci = new Intl.NumberFormat('en-US', {\n  notation: 'scientific',\n  maximumSignificantDigits: 3\n});\n\nsci.format(0.000012345);  // \"1.23E-5\"\n","js",[170],{"type":16,"tag":11,"props":171,"children":172},{"__ignoreMap":7},[173,229,248,262,271,281],{"type":16,"tag":174,"props":175,"children":178},"span",{"class":176,"line":177},"line",1,[179,185,191,196,201,207,213,218,224],{"type":16,"tag":174,"props":180,"children":182},{"style":181},"--shiki-default:#F97583",[183],{"type":25,"value":184},"const",{"type":16,"tag":174,"props":186,"children":188},{"style":187},"--shiki-default:#79B8FF",[189],{"type":25,"value":190}," sci",{"type":16,"tag":174,"props":192,"children":193},{"style":181},[194],{"type":25,"value":195}," =",{"type":16,"tag":174,"props":197,"children":198},{"style":181},[199],{"type":25,"value":200}," new",{"type":16,"tag":174,"props":202,"children":204},{"style":203},"--shiki-default:#E1E4E8",[205],{"type":25,"value":206}," Intl.",{"type":16,"tag":174,"props":208,"children":210},{"style":209},"--shiki-default:#B392F0",[211],{"type":25,"value":212},"NumberFormat",{"type":16,"tag":174,"props":214,"children":215},{"style":203},[216],{"type":25,"value":217},"(",{"type":16,"tag":174,"props":219,"children":221},{"style":220},"--shiki-default:#9ECBFF",[222],{"type":25,"value":223},"'en-US'",{"type":16,"tag":174,"props":225,"children":226},{"style":203},[227],{"type":25,"value":228},", {\n",{"type":16,"tag":174,"props":230,"children":232},{"class":176,"line":231},2,[233,238,243],{"type":16,"tag":174,"props":234,"children":235},{"style":203},[236],{"type":25,"value":237},"  notation: ",{"type":16,"tag":174,"props":239,"children":240},{"style":220},[241],{"type":25,"value":242},"'scientific'",{"type":16,"tag":174,"props":244,"children":245},{"style":203},[246],{"type":25,"value":247},",\n",{"type":16,"tag":174,"props":249,"children":251},{"class":176,"line":250},3,[252,257],{"type":16,"tag":174,"props":253,"children":254},{"style":203},[255],{"type":25,"value":256},"  maximumSignificantDigits: ",{"type":16,"tag":174,"props":258,"children":259},{"style":187},[260],{"type":25,"value":261},"3\n",{"type":16,"tag":174,"props":263,"children":265},{"class":176,"line":264},4,[266],{"type":16,"tag":174,"props":267,"children":268},{"style":203},[269],{"type":25,"value":270},"});\n",{"type":16,"tag":174,"props":272,"children":274},{"class":176,"line":273},5,[275],{"type":16,"tag":174,"props":276,"children":278},{"emptyLinePlaceholder":277},true,[279],{"type":25,"value":280},"\n",{"type":16,"tag":174,"props":282,"children":284},{"class":176,"line":283},6,[285,290,295,299,304,309],{"type":16,"tag":174,"props":286,"children":287},{"style":203},[288],{"type":25,"value":289},"sci.",{"type":16,"tag":174,"props":291,"children":292},{"style":209},[293],{"type":25,"value":294},"format",{"type":16,"tag":174,"props":296,"children":297},{"style":203},[298],{"type":25,"value":217},{"type":16,"tag":174,"props":300,"children":301},{"style":187},[302],{"type":25,"value":303},"0.000012345",{"type":16,"tag":174,"props":305,"children":306},{"style":203},[307],{"type":25,"value":308},");  ",{"type":16,"tag":174,"props":310,"children":312},{"style":311},"--shiki-default:#6A737D",[313],{"type":25,"value":314},"// \"1.23E-5\"\n",{"type":16,"tag":316,"props":317,"children":318},"code-description",{},[319],{"type":16,"tag":21,"props":320,"children":321},{},[322,328,330,336,338,344],{"type":16,"tag":11,"props":323,"children":325},{"className":324},[],[326],{"type":25,"value":327},"notation: 'scientific'",{"type":25,"value":329}," does the hard part: rounding and choosing the exponent. But ",{"type":16,"tag":11,"props":331,"children":333},{"className":332},[],[334],{"type":25,"value":335},"1.23E-5",{"type":25,"value":337}," is programmer notation. On screen, people expect ",{"type":16,"tag":11,"props":339,"children":341},{"className":340},[],[342],{"type":25,"value":343},"1.23 × 10⁻⁵",{"type":25,"value":345},".",{"type":16,"tag":36,"props":347,"children":348},{},[349],{"type":16,"tag":21,"props":350,"children":351},{},[352,358],{"type":16,"tag":11,"props":353,"children":355},{"className":354},[],[356],{"type":25,"value":357},"formatToParts",{"type":25,"value":359}," returns the same output split into labeled pieces, so the exponent can be pulled out and rewritten:",{"type":16,"tag":160,"props":361,"children":362},{},[363],{"type":16,"tag":164,"props":364,"children":366},{"className":166,"code":365,"language":168,"meta":7,"style":7},"sci.formatToParts(-0.000012345);\n// [\n//   { type: 'minusSign',         value: '-' },\n//   { type: 'integer',           value: '1' },\n//   { type: 'decimal',           value: '.' },\n//   { type: 'fraction',          value: '23' },\n//   { type: 'exponentSeparator', value: 'E' },\n//   { type: 'exponentMinusSign', value: '-' },\n//   { type: 'exponentInteger',   value: '5' }\n// ]\n",[367],{"type":16,"tag":11,"props":368,"children":369},{"__ignoreMap":7},[370,399,407,415,423,431,439,448,457,466],{"type":16,"tag":174,"props":371,"children":372},{"class":176,"line":177},[373,377,381,385,390,394],{"type":16,"tag":174,"props":374,"children":375},{"style":203},[376],{"type":25,"value":289},{"type":16,"tag":174,"props":378,"children":379},{"style":209},[380],{"type":25,"value":357},{"type":16,"tag":174,"props":382,"children":383},{"style":203},[384],{"type":25,"value":217},{"type":16,"tag":174,"props":386,"children":387},{"style":181},[388],{"type":25,"value":389},"-",{"type":16,"tag":174,"props":391,"children":392},{"style":187},[393],{"type":25,"value":303},{"type":16,"tag":174,"props":395,"children":396},{"style":203},[397],{"type":25,"value":398},");\n",{"type":16,"tag":174,"props":400,"children":401},{"class":176,"line":231},[402],{"type":16,"tag":174,"props":403,"children":404},{"style":311},[405],{"type":25,"value":406},"// [\n",{"type":16,"tag":174,"props":408,"children":409},{"class":176,"line":250},[410],{"type":16,"tag":174,"props":411,"children":412},{"style":311},[413],{"type":25,"value":414},"//   { type: 'minusSign',         value: '-' },\n",{"type":16,"tag":174,"props":416,"children":417},{"class":176,"line":264},[418],{"type":16,"tag":174,"props":419,"children":420},{"style":311},[421],{"type":25,"value":422},"//   { type: 'integer',           value: '1' },\n",{"type":16,"tag":174,"props":424,"children":425},{"class":176,"line":273},[426],{"type":16,"tag":174,"props":427,"children":428},{"style":311},[429],{"type":25,"value":430},"//   { type: 'decimal',           value: '.' },\n",{"type":16,"tag":174,"props":432,"children":433},{"class":176,"line":283},[434],{"type":16,"tag":174,"props":435,"children":436},{"style":311},[437],{"type":25,"value":438},"//   { type: 'fraction',          value: '23' },\n",{"type":16,"tag":174,"props":440,"children":442},{"class":176,"line":441},7,[443],{"type":16,"tag":174,"props":444,"children":445},{"style":311},[446],{"type":25,"value":447},"//   { type: 'exponentSeparator', value: 'E' },\n",{"type":16,"tag":174,"props":449,"children":451},{"class":176,"line":450},8,[452],{"type":16,"tag":174,"props":453,"children":454},{"style":311},[455],{"type":25,"value":456},"//   { type: 'exponentMinusSign', value: '-' },\n",{"type":16,"tag":174,"props":458,"children":460},{"class":176,"line":459},9,[461],{"type":16,"tag":174,"props":462,"children":463},{"style":311},[464],{"type":25,"value":465},"//   { type: 'exponentInteger',   value: '5' }\n",{"type":16,"tag":174,"props":467,"children":469},{"class":176,"line":468},10,[470],{"type":16,"tag":174,"props":471,"children":472},{"style":311},[473],{"type":25,"value":474},"// ]\n",{"type":16,"tag":151,"props":476,"children":477},{},[478],{"type":16,"tag":21,"props":479,"children":480},{},[481],{"type":25,"value":482},"A helper for × 10ⁿ",{"type":16,"tag":160,"props":484,"children":485},{},[486],{"type":16,"tag":164,"props":487,"children":489},{"className":166,"code":488,"language":168,"meta":7,"style":7},"const SUPERSCRIPT = {\n  '0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴',\n  '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹', '-': '⁻'\n};\n\n// Split Intl's output into the number part and the exponent\nfunction split(value, notation, digits) {\n  const parts = new Intl.NumberFormat('en-US', {\n    notation,\n    minimumSignificantDigits: digits,\n    maximumSignificantDigits: digits\n  }).formatToParts(value);\n\n  let mantissa = '';\n  let exponent = '';\n  for (const part of parts) {\n    if (part.type === 'exponentSeparator') continue;\n    if (part.type === 'exponentMinusSign' || part.type === 'exponentInteger') exponent += part.value;\n    else mantissa += part.value;\n  }\n  return { mantissa, exponent: Number(exponent) };\n}\n\nfunction toScientific(value, digits = 3) {\n  const { mantissa, exponent } = split(value, 'scientific', digits);\n  const superscript = [...String(exponent)].map(c => SUPERSCRIPT[c]).join('');\n  return `${mantissa} × 10${superscript}`;\n}\n\ntoScientific(0.000012345);    // \"1.23 × 10⁻⁵\"\ntoScientific(6.02214076e23);  // \"6.02 × 10²³\"\n",[490],{"type":16,"tag":11,"props":491,"children":492},{"__ignoreMap":7},[493,514,609,716,724,731,739,785,826,834,842,851,869,877,906,931,964,1002,1057,1078,1087,1111,1120,1128,1170,1224,1307,1343,1351,1359,1386],{"type":16,"tag":174,"props":494,"children":495},{"class":176,"line":177},[496,500,505,509],{"type":16,"tag":174,"props":497,"children":498},{"style":181},[499],{"type":25,"value":184},{"type":16,"tag":174,"props":501,"children":502},{"style":187},[503],{"type":25,"value":504}," SUPERSCRIPT",{"type":16,"tag":174,"props":506,"children":507},{"style":181},[508],{"type":25,"value":195},{"type":16,"tag":174,"props":510,"children":511},{"style":203},[512],{"type":25,"value":513}," {\n",{"type":16,"tag":174,"props":515,"children":516},{"class":176,"line":231},[517,522,527,532,537,542,546,551,555,560,564,569,573,578,582,587,591,596,600,605],{"type":16,"tag":174,"props":518,"children":519},{"style":220},[520],{"type":25,"value":521},"  '0'",{"type":16,"tag":174,"props":523,"children":524},{"style":203},[525],{"type":25,"value":526},": ",{"type":16,"tag":174,"props":528,"children":529},{"style":220},[530],{"type":25,"value":531},"'⁰'",{"type":16,"tag":174,"props":533,"children":534},{"style":203},[535],{"type":25,"value":536},", ",{"type":16,"tag":174,"props":538,"children":539},{"style":220},[540],{"type":25,"value":541},"'1'",{"type":16,"tag":174,"props":543,"children":544},{"style":203},[545],{"type":25,"value":526},{"type":16,"tag":174,"props":547,"children":548},{"style":220},[549],{"type":25,"value":550},"'¹'",{"type":16,"tag":174,"props":552,"children":553},{"style":203},[554],{"type":25,"value":536},{"type":16,"tag":174,"props":556,"children":557},{"style":220},[558],{"type":25,"value":559},"'2'",{"type":16,"tag":174,"props":561,"children":562},{"style":203},[563],{"type":25,"value":526},{"type":16,"tag":174,"props":565,"children":566},{"style":220},[567],{"type":25,"value":568},"'²'",{"type":16,"tag":174,"props":570,"children":571},{"style":203},[572],{"type":25,"value":536},{"type":16,"tag":174,"props":574,"children":575},{"style":220},[576],{"type":25,"value":577},"'3'",{"type":16,"tag":174,"props":579,"children":580},{"style":203},[581],{"type":25,"value":526},{"type":16,"tag":174,"props":583,"children":584},{"style":220},[585],{"type":25,"value":586},"'³'",{"type":16,"tag":174,"props":588,"children":589},{"style":203},[590],{"type":25,"value":536},{"type":16,"tag":174,"props":592,"children":593},{"style":220},[594],{"type":25,"value":595},"'4'",{"type":16,"tag":174,"props":597,"children":598},{"style":203},[599],{"type":25,"value":526},{"type":16,"tag":174,"props":601,"children":602},{"style":220},[603],{"type":25,"value":604},"'⁴'",{"type":16,"tag":174,"props":606,"children":607},{"style":203},[608],{"type":25,"value":247},{"type":16,"tag":174,"props":610,"children":611},{"class":176,"line":250},[612,617,621,626,630,635,639,644,648,653,657,662,666,671,675,680,684,689,693,698,702,707,711],{"type":16,"tag":174,"props":613,"children":614},{"style":220},[615],{"type":25,"value":616},"  '5'",{"type":16,"tag":174,"props":618,"children":619},{"style":203},[620],{"type":25,"value":526},{"type":16,"tag":174,"props":622,"children":623},{"style":220},[624],{"type":25,"value":625},"'⁵'",{"type":16,"tag":174,"props":627,"children":628},{"style":203},[629],{"type":25,"value":536},{"type":16,"tag":174,"props":631,"children":632},{"style":220},[633],{"type":25,"value":634},"'6'",{"type":16,"tag":174,"props":636,"children":637},{"style":203},[638],{"type":25,"value":526},{"type":16,"tag":174,"props":640,"children":641},{"style":220},[642],{"type":25,"value":643},"'⁶'",{"type":16,"tag":174,"props":645,"children":646},{"style":203},[647],{"type":25,"value":536},{"type":16,"tag":174,"props":649,"children":650},{"style":220},[651],{"type":25,"value":652},"'7'",{"type":16,"tag":174,"props":654,"children":655},{"style":203},[656],{"type":25,"value":526},{"type":16,"tag":174,"props":658,"children":659},{"style":220},[660],{"type":25,"value":661},"'⁷'",{"type":16,"tag":174,"props":663,"children":664},{"style":203},[665],{"type":25,"value":536},{"type":16,"tag":174,"props":667,"children":668},{"style":220},[669],{"type":25,"value":670},"'8'",{"type":16,"tag":174,"props":672,"children":673},{"style":203},[674],{"type":25,"value":526},{"type":16,"tag":174,"props":676,"children":677},{"style":220},[678],{"type":25,"value":679},"'⁸'",{"type":16,"tag":174,"props":681,"children":682},{"style":203},[683],{"type":25,"value":536},{"type":16,"tag":174,"props":685,"children":686},{"style":220},[687],{"type":25,"value":688},"'9'",{"type":16,"tag":174,"props":690,"children":691},{"style":203},[692],{"type":25,"value":526},{"type":16,"tag":174,"props":694,"children":695},{"style":220},[696],{"type":25,"value":697},"'⁹'",{"type":16,"tag":174,"props":699,"children":700},{"style":203},[701],{"type":25,"value":536},{"type":16,"tag":174,"props":703,"children":704},{"style":220},[705],{"type":25,"value":706},"'-'",{"type":16,"tag":174,"props":708,"children":709},{"style":203},[710],{"type":25,"value":526},{"type":16,"tag":174,"props":712,"children":713},{"style":220},[714],{"type":25,"value":715},"'⁻'\n",{"type":16,"tag":174,"props":717,"children":718},{"class":176,"line":264},[719],{"type":16,"tag":174,"props":720,"children":721},{"style":203},[722],{"type":25,"value":723},"};\n",{"type":16,"tag":174,"props":725,"children":726},{"class":176,"line":273},[727],{"type":16,"tag":174,"props":728,"children":729},{"emptyLinePlaceholder":277},[730],{"type":25,"value":280},{"type":16,"tag":174,"props":732,"children":733},{"class":176,"line":283},[734],{"type":16,"tag":174,"props":735,"children":736},{"style":311},[737],{"type":25,"value":738},"// Split Intl's output into the number part and the exponent\n",{"type":16,"tag":174,"props":740,"children":741},{"class":176,"line":441},[742,747,752,756,762,766,771,775,780],{"type":16,"tag":174,"props":743,"children":744},{"style":181},[745],{"type":25,"value":746},"function",{"type":16,"tag":174,"props":748,"children":749},{"style":209},[750],{"type":25,"value":751}," split",{"type":16,"tag":174,"props":753,"children":754},{"style":203},[755],{"type":25,"value":217},{"type":16,"tag":174,"props":757,"children":759},{"style":758},"--shiki-default:#FFAB70",[760],{"type":25,"value":761},"value",{"type":16,"tag":174,"props":763,"children":764},{"style":203},[765],{"type":25,"value":536},{"type":16,"tag":174,"props":767,"children":768},{"style":758},[769],{"type":25,"value":770},"notation",{"type":16,"tag":174,"props":772,"children":773},{"style":203},[774],{"type":25,"value":536},{"type":16,"tag":174,"props":776,"children":777},{"style":758},[778],{"type":25,"value":779},"digits",{"type":16,"tag":174,"props":781,"children":782},{"style":203},[783],{"type":25,"value":784},") {\n",{"type":16,"tag":174,"props":786,"children":787},{"class":176,"line":450},[788,793,798,802,806,810,814,818,822],{"type":16,"tag":174,"props":789,"children":790},{"style":181},[791],{"type":25,"value":792},"  const",{"type":16,"tag":174,"props":794,"children":795},{"style":187},[796],{"type":25,"value":797}," parts",{"type":16,"tag":174,"props":799,"children":800},{"style":181},[801],{"type":25,"value":195},{"type":16,"tag":174,"props":803,"children":804},{"style":181},[805],{"type":25,"value":200},{"type":16,"tag":174,"props":807,"children":808},{"style":203},[809],{"type":25,"value":206},{"type":16,"tag":174,"props":811,"children":812},{"style":209},[813],{"type":25,"value":212},{"type":16,"tag":174,"props":815,"children":816},{"style":203},[817],{"type":25,"value":217},{"type":16,"tag":174,"props":819,"children":820},{"style":220},[821],{"type":25,"value":223},{"type":16,"tag":174,"props":823,"children":824},{"style":203},[825],{"type":25,"value":228},{"type":16,"tag":174,"props":827,"children":828},{"class":176,"line":459},[829],{"type":16,"tag":174,"props":830,"children":831},{"style":203},[832],{"type":25,"value":833},"    notation,\n",{"type":16,"tag":174,"props":835,"children":836},{"class":176,"line":468},[837],{"type":16,"tag":174,"props":838,"children":839},{"style":203},[840],{"type":25,"value":841},"    minimumSignificantDigits: digits,\n",{"type":16,"tag":174,"props":843,"children":845},{"class":176,"line":844},11,[846],{"type":16,"tag":174,"props":847,"children":848},{"style":203},[849],{"type":25,"value":850},"    maximumSignificantDigits: digits\n",{"type":16,"tag":174,"props":852,"children":854},{"class":176,"line":853},12,[855,860,864],{"type":16,"tag":174,"props":856,"children":857},{"style":203},[858],{"type":25,"value":859},"  }).",{"type":16,"tag":174,"props":861,"children":862},{"style":209},[863],{"type":25,"value":357},{"type":16,"tag":174,"props":865,"children":866},{"style":203},[867],{"type":25,"value":868},"(value);\n",{"type":16,"tag":174,"props":870,"children":872},{"class":176,"line":871},13,[873],{"type":16,"tag":174,"props":874,"children":875},{"emptyLinePlaceholder":277},[876],{"type":25,"value":280},{"type":16,"tag":174,"props":878,"children":880},{"class":176,"line":879},14,[881,886,891,896,901],{"type":16,"tag":174,"props":882,"children":883},{"style":181},[884],{"type":25,"value":885},"  let",{"type":16,"tag":174,"props":887,"children":888},{"style":203},[889],{"type":25,"value":890}," mantissa ",{"type":16,"tag":174,"props":892,"children":893},{"style":181},[894],{"type":25,"value":895},"=",{"type":16,"tag":174,"props":897,"children":898},{"style":220},[899],{"type":25,"value":900}," ''",{"type":16,"tag":174,"props":902,"children":903},{"style":203},[904],{"type":25,"value":905},";\n",{"type":16,"tag":174,"props":907,"children":909},{"class":176,"line":908},15,[910,914,919,923,927],{"type":16,"tag":174,"props":911,"children":912},{"style":181},[913],{"type":25,"value":885},{"type":16,"tag":174,"props":915,"children":916},{"style":203},[917],{"type":25,"value":918}," exponent ",{"type":16,"tag":174,"props":920,"children":921},{"style":181},[922],{"type":25,"value":895},{"type":16,"tag":174,"props":924,"children":925},{"style":220},[926],{"type":25,"value":900},{"type":16,"tag":174,"props":928,"children":929},{"style":203},[930],{"type":25,"value":905},{"type":16,"tag":174,"props":932,"children":934},{"class":176,"line":933},16,[935,940,945,949,954,959],{"type":16,"tag":174,"props":936,"children":937},{"style":181},[938],{"type":25,"value":939},"  for",{"type":16,"tag":174,"props":941,"children":942},{"style":203},[943],{"type":25,"value":944}," (",{"type":16,"tag":174,"props":946,"children":947},{"style":181},[948],{"type":25,"value":184},{"type":16,"tag":174,"props":950,"children":951},{"style":187},[952],{"type":25,"value":953}," part",{"type":16,"tag":174,"props":955,"children":956},{"style":181},[957],{"type":25,"value":958}," of",{"type":16,"tag":174,"props":960,"children":961},{"style":203},[962],{"type":25,"value":963}," parts) {\n",{"type":16,"tag":174,"props":965,"children":967},{"class":176,"line":966},17,[968,973,978,983,988,993,998],{"type":16,"tag":174,"props":969,"children":970},{"style":181},[971],{"type":25,"value":972},"    if",{"type":16,"tag":174,"props":974,"children":975},{"style":203},[976],{"type":25,"value":977}," (part.type ",{"type":16,"tag":174,"props":979,"children":980},{"style":181},[981],{"type":25,"value":982},"===",{"type":16,"tag":174,"props":984,"children":985},{"style":220},[986],{"type":25,"value":987}," 'exponentSeparator'",{"type":16,"tag":174,"props":989,"children":990},{"style":203},[991],{"type":25,"value":992},") ",{"type":16,"tag":174,"props":994,"children":995},{"style":181},[996],{"type":25,"value":997},"continue",{"type":16,"tag":174,"props":999,"children":1000},{"style":203},[1001],{"type":25,"value":905},{"type":16,"tag":174,"props":1003,"children":1005},{"class":176,"line":1004},18,[1006,1010,1014,1018,1023,1028,1033,1037,1042,1047,1052],{"type":16,"tag":174,"props":1007,"children":1008},{"style":181},[1009],{"type":25,"value":972},{"type":16,"tag":174,"props":1011,"children":1012},{"style":203},[1013],{"type":25,"value":977},{"type":16,"tag":174,"props":1015,"children":1016},{"style":181},[1017],{"type":25,"value":982},{"type":16,"tag":174,"props":1019,"children":1020},{"style":220},[1021],{"type":25,"value":1022}," 'exponentMinusSign'",{"type":16,"tag":174,"props":1024,"children":1025},{"style":181},[1026],{"type":25,"value":1027}," ||",{"type":16,"tag":174,"props":1029,"children":1030},{"style":203},[1031],{"type":25,"value":1032}," part.type ",{"type":16,"tag":174,"props":1034,"children":1035},{"style":181},[1036],{"type":25,"value":982},{"type":16,"tag":174,"props":1038,"children":1039},{"style":220},[1040],{"type":25,"value":1041}," 'exponentInteger'",{"type":16,"tag":174,"props":1043,"children":1044},{"style":203},[1045],{"type":25,"value":1046},") exponent ",{"type":16,"tag":174,"props":1048,"children":1049},{"style":181},[1050],{"type":25,"value":1051},"+=",{"type":16,"tag":174,"props":1053,"children":1054},{"style":203},[1055],{"type":25,"value":1056}," part.value;\n",{"type":16,"tag":174,"props":1058,"children":1060},{"class":176,"line":1059},19,[1061,1066,1070,1074],{"type":16,"tag":174,"props":1062,"children":1063},{"style":181},[1064],{"type":25,"value":1065},"    else",{"type":16,"tag":174,"props":1067,"children":1068},{"style":203},[1069],{"type":25,"value":890},{"type":16,"tag":174,"props":1071,"children":1072},{"style":181},[1073],{"type":25,"value":1051},{"type":16,"tag":174,"props":1075,"children":1076},{"style":203},[1077],{"type":25,"value":1056},{"type":16,"tag":174,"props":1079,"children":1081},{"class":176,"line":1080},20,[1082],{"type":16,"tag":174,"props":1083,"children":1084},{"style":203},[1085],{"type":25,"value":1086},"  }\n",{"type":16,"tag":174,"props":1088,"children":1090},{"class":176,"line":1089},21,[1091,1096,1101,1106],{"type":16,"tag":174,"props":1092,"children":1093},{"style":181},[1094],{"type":25,"value":1095},"  return",{"type":16,"tag":174,"props":1097,"children":1098},{"style":203},[1099],{"type":25,"value":1100}," { mantissa, exponent: ",{"type":16,"tag":174,"props":1102,"children":1103},{"style":209},[1104],{"type":25,"value":1105},"Number",{"type":16,"tag":174,"props":1107,"children":1108},{"style":203},[1109],{"type":25,"value":1110},"(exponent) };\n",{"type":16,"tag":174,"props":1112,"children":1114},{"class":176,"line":1113},22,[1115],{"type":16,"tag":174,"props":1116,"children":1117},{"style":203},[1118],{"type":25,"value":1119},"}\n",{"type":16,"tag":174,"props":1121,"children":1123},{"class":176,"line":1122},23,[1124],{"type":16,"tag":174,"props":1125,"children":1126},{"emptyLinePlaceholder":277},[1127],{"type":25,"value":280},{"type":16,"tag":174,"props":1129,"children":1131},{"class":176,"line":1130},24,[1132,1136,1141,1145,1149,1153,1157,1161,1166],{"type":16,"tag":174,"props":1133,"children":1134},{"style":181},[1135],{"type":25,"value":746},{"type":16,"tag":174,"props":1137,"children":1138},{"style":209},[1139],{"type":25,"value":1140}," toScientific",{"type":16,"tag":174,"props":1142,"children":1143},{"style":203},[1144],{"type":25,"value":217},{"type":16,"tag":174,"props":1146,"children":1147},{"style":758},[1148],{"type":25,"value":761},{"type":16,"tag":174,"props":1150,"children":1151},{"style":203},[1152],{"type":25,"value":536},{"type":16,"tag":174,"props":1154,"children":1155},{"style":758},[1156],{"type":25,"value":779},{"type":16,"tag":174,"props":1158,"children":1159},{"style":181},[1160],{"type":25,"value":195},{"type":16,"tag":174,"props":1162,"children":1163},{"style":187},[1164],{"type":25,"value":1165}," 3",{"type":16,"tag":174,"props":1167,"children":1168},{"style":203},[1169],{"type":25,"value":784},{"type":16,"tag":174,"props":1171,"children":1173},{"class":176,"line":1172},25,[1174,1178,1183,1188,1192,1197,1202,1206,1210,1215,1219],{"type":16,"tag":174,"props":1175,"children":1176},{"style":181},[1177],{"type":25,"value":792},{"type":16,"tag":174,"props":1179,"children":1180},{"style":203},[1181],{"type":25,"value":1182}," { ",{"type":16,"tag":174,"props":1184,"children":1185},{"style":187},[1186],{"type":25,"value":1187},"mantissa",{"type":16,"tag":174,"props":1189,"children":1190},{"style":203},[1191],{"type":25,"value":536},{"type":16,"tag":174,"props":1193,"children":1194},{"style":187},[1195],{"type":25,"value":1196},"exponent",{"type":16,"tag":174,"props":1198,"children":1199},{"style":203},[1200],{"type":25,"value":1201}," } ",{"type":16,"tag":174,"props":1203,"children":1204},{"style":181},[1205],{"type":25,"value":895},{"type":16,"tag":174,"props":1207,"children":1208},{"style":209},[1209],{"type":25,"value":751},{"type":16,"tag":174,"props":1211,"children":1212},{"style":203},[1213],{"type":25,"value":1214},"(value, ",{"type":16,"tag":174,"props":1216,"children":1217},{"style":220},[1218],{"type":25,"value":242},{"type":16,"tag":174,"props":1220,"children":1221},{"style":203},[1222],{"type":25,"value":1223},", digits);\n",{"type":16,"tag":174,"props":1225,"children":1227},{"class":176,"line":1226},26,[1228,1232,1237,1241,1246,1251,1256,1261,1266,1270,1275,1280,1284,1289,1294,1298,1303],{"type":16,"tag":174,"props":1229,"children":1230},{"style":181},[1231],{"type":25,"value":792},{"type":16,"tag":174,"props":1233,"children":1234},{"style":187},[1235],{"type":25,"value":1236}," superscript",{"type":16,"tag":174,"props":1238,"children":1239},{"style":181},[1240],{"type":25,"value":195},{"type":16,"tag":174,"props":1242,"children":1243},{"style":203},[1244],{"type":25,"value":1245}," [",{"type":16,"tag":174,"props":1247,"children":1248},{"style":181},[1249],{"type":25,"value":1250},"...",{"type":16,"tag":174,"props":1252,"children":1253},{"style":209},[1254],{"type":25,"value":1255},"String",{"type":16,"tag":174,"props":1257,"children":1258},{"style":203},[1259],{"type":25,"value":1260},"(exponent)].",{"type":16,"tag":174,"props":1262,"children":1263},{"style":209},[1264],{"type":25,"value":1265},"map",{"type":16,"tag":174,"props":1267,"children":1268},{"style":203},[1269],{"type":25,"value":217},{"type":16,"tag":174,"props":1271,"children":1272},{"style":758},[1273],{"type":25,"value":1274},"c",{"type":16,"tag":174,"props":1276,"children":1277},{"style":181},[1278],{"type":25,"value":1279}," =>",{"type":16,"tag":174,"props":1281,"children":1282},{"style":187},[1283],{"type":25,"value":504},{"type":16,"tag":174,"props":1285,"children":1286},{"style":203},[1287],{"type":25,"value":1288},"[c]).",{"type":16,"tag":174,"props":1290,"children":1291},{"style":209},[1292],{"type":25,"value":1293},"join",{"type":16,"tag":174,"props":1295,"children":1296},{"style":203},[1297],{"type":25,"value":217},{"type":16,"tag":174,"props":1299,"children":1300},{"style":220},[1301],{"type":25,"value":1302},"''",{"type":16,"tag":174,"props":1304,"children":1305},{"style":203},[1306],{"type":25,"value":398},{"type":16,"tag":174,"props":1308,"children":1310},{"class":176,"line":1309},27,[1311,1315,1320,1324,1329,1334,1339],{"type":16,"tag":174,"props":1312,"children":1313},{"style":181},[1314],{"type":25,"value":1095},{"type":16,"tag":174,"props":1316,"children":1317},{"style":220},[1318],{"type":25,"value":1319}," `${",{"type":16,"tag":174,"props":1321,"children":1322},{"style":203},[1323],{"type":25,"value":1187},{"type":16,"tag":174,"props":1325,"children":1326},{"style":220},[1327],{"type":25,"value":1328},"} × 10${",{"type":16,"tag":174,"props":1330,"children":1331},{"style":203},[1332],{"type":25,"value":1333},"superscript",{"type":16,"tag":174,"props":1335,"children":1336},{"style":220},[1337],{"type":25,"value":1338},"}`",{"type":16,"tag":174,"props":1340,"children":1341},{"style":203},[1342],{"type":25,"value":905},{"type":16,"tag":174,"props":1344,"children":1346},{"class":176,"line":1345},28,[1347],{"type":16,"tag":174,"props":1348,"children":1349},{"style":203},[1350],{"type":25,"value":1119},{"type":16,"tag":174,"props":1352,"children":1354},{"class":176,"line":1353},29,[1355],{"type":16,"tag":174,"props":1356,"children":1357},{"emptyLinePlaceholder":277},[1358],{"type":25,"value":280},{"type":16,"tag":174,"props":1360,"children":1362},{"class":176,"line":1361},30,[1363,1368,1372,1376,1381],{"type":16,"tag":174,"props":1364,"children":1365},{"style":209},[1366],{"type":25,"value":1367},"toScientific",{"type":16,"tag":174,"props":1369,"children":1370},{"style":203},[1371],{"type":25,"value":217},{"type":16,"tag":174,"props":1373,"children":1374},{"style":187},[1375],{"type":25,"value":303},{"type":16,"tag":174,"props":1377,"children":1378},{"style":203},[1379],{"type":25,"value":1380},");    ",{"type":16,"tag":174,"props":1382,"children":1383},{"style":311},[1384],{"type":25,"value":1385},"// \"1.23 × 10⁻⁵\"\n",{"type":16,"tag":174,"props":1387,"children":1389},{"class":176,"line":1388},31,[1390,1394,1398,1403,1407],{"type":16,"tag":174,"props":1391,"children":1392},{"style":209},[1393],{"type":25,"value":1367},{"type":16,"tag":174,"props":1395,"children":1396},{"style":203},[1397],{"type":25,"value":217},{"type":16,"tag":174,"props":1399,"children":1400},{"style":187},[1401],{"type":25,"value":1402},"6.02214076e23",{"type":16,"tag":174,"props":1404,"children":1405},{"style":203},[1406],{"type":25,"value":308},{"type":16,"tag":174,"props":1408,"children":1409},{"style":311},[1410],{"type":25,"value":1411},"// \"6.02 × 10²³\"\n",{"type":16,"tag":316,"props":1413,"children":1414},{},[1415],{"type":16,"tag":21,"props":1416,"children":1417},{},[1418,1424],{"type":16,"tag":11,"props":1419,"children":1421},{"className":1420},[],[1422],{"type":25,"value":1423},"split",{"type":25,"value":1425}," is reused in the next two sections. Superscript characters keep the result plain text, so it works in tables, tooltips, chart labels, and CSV exports, with no HTML needed.",{"type":16,"tag":151,"props":1427,"children":1428},{},[1429],{"type":16,"tag":21,"props":1430,"children":1431},{},[1432],{"type":25,"value":1433},"Significant figures: keep the trailing zeros",{"type":16,"tag":36,"props":1435,"children":1436},{},[1437],{"type":16,"tag":21,"props":1438,"children":1439},{},[1440,1442,1447,1449,1455,1457,1463],{"type":25,"value":1441},"Notice that ",{"type":16,"tag":11,"props":1443,"children":1445},{"className":1444},[],[1446],{"type":25,"value":1423},{"type":25,"value":1448}," sets both ",{"type":16,"tag":11,"props":1450,"children":1452},{"className":1451},[],[1453],{"type":25,"value":1454},"minimumSignificantDigits",{"type":25,"value":1456}," and ",{"type":16,"tag":11,"props":1458,"children":1460},{"className":1459},[],[1461],{"type":25,"value":1462},"maximumSignificantDigits",{"type":25,"value":1464},". In measurement data, trailing zeros carry meaning:",{"type":16,"tag":160,"props":1466,"children":1467},{},[1468],{"type":16,"tag":164,"props":1469,"children":1471},{"className":166,"code":1470,"language":168,"meta":7,"style":7},"const loose = new Intl.NumberFormat('en-US', { maximumSignificantDigits: 3 });\nconst fixed = new Intl.NumberFormat('en-US', {\n  minimumSignificantDigits: 3,\n  maximumSignificantDigits: 3\n});\n\nloose.format(1.2);  // \"1.2\"\nfixed.format(1.2);  // \"1.20\"   precise to three figures\nfixed.format(20);   // \"20.0\"\n",[1472],{"type":16,"tag":11,"props":1473,"children":1474},{"__ignoreMap":7},[1475,1526,1566,1582,1593,1600,1607,1636,1665],{"type":16,"tag":174,"props":1476,"children":1477},{"class":176,"line":177},[1478,1482,1487,1491,1495,1499,1503,1507,1511,1516,1521],{"type":16,"tag":174,"props":1479,"children":1480},{"style":181},[1481],{"type":25,"value":184},{"type":16,"tag":174,"props":1483,"children":1484},{"style":187},[1485],{"type":25,"value":1486}," loose",{"type":16,"tag":174,"props":1488,"children":1489},{"style":181},[1490],{"type":25,"value":195},{"type":16,"tag":174,"props":1492,"children":1493},{"style":181},[1494],{"type":25,"value":200},{"type":16,"tag":174,"props":1496,"children":1497},{"style":203},[1498],{"type":25,"value":206},{"type":16,"tag":174,"props":1500,"children":1501},{"style":209},[1502],{"type":25,"value":212},{"type":16,"tag":174,"props":1504,"children":1505},{"style":203},[1506],{"type":25,"value":217},{"type":16,"tag":174,"props":1508,"children":1509},{"style":220},[1510],{"type":25,"value":223},{"type":16,"tag":174,"props":1512,"children":1513},{"style":203},[1514],{"type":25,"value":1515},", { maximumSignificantDigits: ",{"type":16,"tag":174,"props":1517,"children":1518},{"style":187},[1519],{"type":25,"value":1520},"3",{"type":16,"tag":174,"props":1522,"children":1523},{"style":203},[1524],{"type":25,"value":1525}," });\n",{"type":16,"tag":174,"props":1527,"children":1528},{"class":176,"line":231},[1529,1533,1538,1542,1546,1550,1554,1558,1562],{"type":16,"tag":174,"props":1530,"children":1531},{"style":181},[1532],{"type":25,"value":184},{"type":16,"tag":174,"props":1534,"children":1535},{"style":187},[1536],{"type":25,"value":1537}," fixed",{"type":16,"tag":174,"props":1539,"children":1540},{"style":181},[1541],{"type":25,"value":195},{"type":16,"tag":174,"props":1543,"children":1544},{"style":181},[1545],{"type":25,"value":200},{"type":16,"tag":174,"props":1547,"children":1548},{"style":203},[1549],{"type":25,"value":206},{"type":16,"tag":174,"props":1551,"children":1552},{"style":209},[1553],{"type":25,"value":212},{"type":16,"tag":174,"props":1555,"children":1556},{"style":203},[1557],{"type":25,"value":217},{"type":16,"tag":174,"props":1559,"children":1560},{"style":220},[1561],{"type":25,"value":223},{"type":16,"tag":174,"props":1563,"children":1564},{"style":203},[1565],{"type":25,"value":228},{"type":16,"tag":174,"props":1567,"children":1568},{"class":176,"line":250},[1569,1574,1578],{"type":16,"tag":174,"props":1570,"children":1571},{"style":203},[1572],{"type":25,"value":1573},"  minimumSignificantDigits: ",{"type":16,"tag":174,"props":1575,"children":1576},{"style":187},[1577],{"type":25,"value":1520},{"type":16,"tag":174,"props":1579,"children":1580},{"style":203},[1581],{"type":25,"value":247},{"type":16,"tag":174,"props":1583,"children":1584},{"class":176,"line":264},[1585,1589],{"type":16,"tag":174,"props":1586,"children":1587},{"style":203},[1588],{"type":25,"value":256},{"type":16,"tag":174,"props":1590,"children":1591},{"style":187},[1592],{"type":25,"value":261},{"type":16,"tag":174,"props":1594,"children":1595},{"class":176,"line":273},[1596],{"type":16,"tag":174,"props":1597,"children":1598},{"style":203},[1599],{"type":25,"value":270},{"type":16,"tag":174,"props":1601,"children":1602},{"class":176,"line":283},[1603],{"type":16,"tag":174,"props":1604,"children":1605},{"emptyLinePlaceholder":277},[1606],{"type":25,"value":280},{"type":16,"tag":174,"props":1608,"children":1609},{"class":176,"line":441},[1610,1615,1619,1623,1627,1631],{"type":16,"tag":174,"props":1611,"children":1612},{"style":203},[1613],{"type":25,"value":1614},"loose.",{"type":16,"tag":174,"props":1616,"children":1617},{"style":209},[1618],{"type":25,"value":294},{"type":16,"tag":174,"props":1620,"children":1621},{"style":203},[1622],{"type":25,"value":217},{"type":16,"tag":174,"props":1624,"children":1625},{"style":187},[1626],{"type":25,"value":117},{"type":16,"tag":174,"props":1628,"children":1629},{"style":203},[1630],{"type":25,"value":308},{"type":16,"tag":174,"props":1632,"children":1633},{"style":311},[1634],{"type":25,"value":1635},"// \"1.2\"\n",{"type":16,"tag":174,"props":1637,"children":1638},{"class":176,"line":450},[1639,1644,1648,1652,1656,1660],{"type":16,"tag":174,"props":1640,"children":1641},{"style":203},[1642],{"type":25,"value":1643},"fixed.",{"type":16,"tag":174,"props":1645,"children":1646},{"style":209},[1647],{"type":25,"value":294},{"type":16,"tag":174,"props":1649,"children":1650},{"style":203},[1651],{"type":25,"value":217},{"type":16,"tag":174,"props":1653,"children":1654},{"style":187},[1655],{"type":25,"value":117},{"type":16,"tag":174,"props":1657,"children":1658},{"style":203},[1659],{"type":25,"value":308},{"type":16,"tag":174,"props":1661,"children":1662},{"style":311},[1663],{"type":25,"value":1664},"// \"1.20\"   precise to three figures\n",{"type":16,"tag":174,"props":1666,"children":1667},{"class":176,"line":459},[1668,1672,1676,1680,1685,1690],{"type":16,"tag":174,"props":1669,"children":1670},{"style":203},[1671],{"type":25,"value":1643},{"type":16,"tag":174,"props":1673,"children":1674},{"style":209},[1675],{"type":25,"value":294},{"type":16,"tag":174,"props":1677,"children":1678},{"style":203},[1679],{"type":25,"value":217},{"type":16,"tag":174,"props":1681,"children":1682},{"style":187},[1683],{"type":25,"value":1684},"20",{"type":16,"tag":174,"props":1686,"children":1687},{"style":203},[1688],{"type":25,"value":1689},");   ",{"type":16,"tag":174,"props":1691,"children":1692},{"style":311},[1693],{"type":25,"value":1694},"// \"20.0\"\n",{"type":16,"tag":316,"props":1696,"children":1697},{},[1698],{"type":16,"tag":21,"props":1699,"children":1700},{},[1701,1706,1707,1712],{"type":16,"tag":11,"props":1702,"children":1704},{"className":1703},[],[1705],{"type":25,"value":117},{"type":25,"value":1456},{"type":16,"tag":11,"props":1708,"children":1710},{"className":1709},[],[1711],{"type":25,"value":110},{"type":25,"value":1713}," are different claims: the second says the instrument measured the hundredths place. Setting only the maximum silently drops that information.",{"type":16,"tag":151,"props":1715,"children":1716},{},[1717],{"type":16,"tag":21,"props":1718,"children":1719},{},[1720],{"type":25,"value":1721},"Switching to scientific notation automatically",{"type":16,"tag":36,"props":1723,"children":1724},{},[1725],{"type":16,"tag":21,"props":1726,"children":1727},{},[1728],{"type":25,"value":1729},"Most values read best as plain numbers. Only very small or very large ones need scientific notation:",{"type":16,"tag":160,"props":1731,"children":1732},{},[1733],{"type":16,"tag":164,"props":1734,"children":1736},{"className":166,"code":1735,"language":168,"meta":7,"style":7},"function formatValue(value, { digits = 3, min = 0.001, max = 1e6 } = {}) {\n  if (!Number.isFinite(value)) return '—';\n  if (value === 0) return '0';\n\n  // Decide on the rounded value, so 999,999 at 3 digits becomes 1.00 × 10⁶, not \"1,000,000\"\n  const rounded = Math.abs(Number(value.toPrecision(digits)));\n  if (rounded \u003C min || rounded >= max) return toScientific(value, digits);\n\n  return new Intl.NumberFormat('en-US', {\n    minimumSignificantDigits: digits,\n    maximumSignificantDigits: digits\n  }).format(value);\n}\n\nformatValue(0.0042);     // \"0.00420\"\nformatValue(0.00042);    // \"4.20 × 10⁻⁴\"\nformatValue(123.456);    // \"123\"\nformatValue(999999);     // \"1.00 × 10⁶\"\nformatValue(NaN);        // \"—\"\n",[1737],{"type":16,"tag":11,"props":1738,"children":1739},{"__ignoreMap":7},[1740,1826,1872,1910,1917,1925,1974,2029,2036,2067,2074,2081,2096,2103,2110,2137,2162,2187,2212],{"type":16,"tag":174,"props":1741,"children":1742},{"class":176,"line":177},[1743,1747,1752,1756,1760,1765,1769,1773,1777,1781,1786,1790,1795,1799,1804,1808,1813,1817,1821],{"type":16,"tag":174,"props":1744,"children":1745},{"style":181},[1746],{"type":25,"value":746},{"type":16,"tag":174,"props":1748,"children":1749},{"style":209},[1750],{"type":25,"value":1751}," formatValue",{"type":16,"tag":174,"props":1753,"children":1754},{"style":203},[1755],{"type":25,"value":217},{"type":16,"tag":174,"props":1757,"children":1758},{"style":758},[1759],{"type":25,"value":761},{"type":16,"tag":174,"props":1761,"children":1762},{"style":203},[1763],{"type":25,"value":1764},", { ",{"type":16,"tag":174,"props":1766,"children":1767},{"style":758},[1768],{"type":25,"value":779},{"type":16,"tag":174,"props":1770,"children":1771},{"style":181},[1772],{"type":25,"value":195},{"type":16,"tag":174,"props":1774,"children":1775},{"style":187},[1776],{"type":25,"value":1165},{"type":16,"tag":174,"props":1778,"children":1779},{"style":203},[1780],{"type":25,"value":536},{"type":16,"tag":174,"props":1782,"children":1783},{"style":758},[1784],{"type":25,"value":1785},"min",{"type":16,"tag":174,"props":1787,"children":1788},{"style":181},[1789],{"type":25,"value":195},{"type":16,"tag":174,"props":1791,"children":1792},{"style":187},[1793],{"type":25,"value":1794}," 0.001",{"type":16,"tag":174,"props":1796,"children":1797},{"style":203},[1798],{"type":25,"value":536},{"type":16,"tag":174,"props":1800,"children":1801},{"style":758},[1802],{"type":25,"value":1803},"max",{"type":16,"tag":174,"props":1805,"children":1806},{"style":181},[1807],{"type":25,"value":195},{"type":16,"tag":174,"props":1809,"children":1810},{"style":187},[1811],{"type":25,"value":1812}," 1e6",{"type":16,"tag":174,"props":1814,"children":1815},{"style":203},[1816],{"type":25,"value":1201},{"type":16,"tag":174,"props":1818,"children":1819},{"style":181},[1820],{"type":25,"value":895},{"type":16,"tag":174,"props":1822,"children":1823},{"style":203},[1824],{"type":25,"value":1825}," {}) {\n",{"type":16,"tag":174,"props":1827,"children":1828},{"class":176,"line":231},[1829,1834,1838,1843,1848,1853,1858,1863,1868],{"type":16,"tag":174,"props":1830,"children":1831},{"style":181},[1832],{"type":25,"value":1833},"  if",{"type":16,"tag":174,"props":1835,"children":1836},{"style":203},[1837],{"type":25,"value":944},{"type":16,"tag":174,"props":1839,"children":1840},{"style":181},[1841],{"type":25,"value":1842},"!",{"type":16,"tag":174,"props":1844,"children":1845},{"style":203},[1846],{"type":25,"value":1847},"Number.",{"type":16,"tag":174,"props":1849,"children":1850},{"style":209},[1851],{"type":25,"value":1852},"isFinite",{"type":16,"tag":174,"props":1854,"children":1855},{"style":203},[1856],{"type":25,"value":1857},"(value)) ",{"type":16,"tag":174,"props":1859,"children":1860},{"style":181},[1861],{"type":25,"value":1862},"return",{"type":16,"tag":174,"props":1864,"children":1865},{"style":220},[1866],{"type":25,"value":1867}," '—'",{"type":16,"tag":174,"props":1869,"children":1870},{"style":203},[1871],{"type":25,"value":905},{"type":16,"tag":174,"props":1873,"children":1874},{"class":176,"line":250},[1875,1879,1884,1888,1893,1897,1901,1906],{"type":16,"tag":174,"props":1876,"children":1877},{"style":181},[1878],{"type":25,"value":1833},{"type":16,"tag":174,"props":1880,"children":1881},{"style":203},[1882],{"type":25,"value":1883}," (value ",{"type":16,"tag":174,"props":1885,"children":1886},{"style":181},[1887],{"type":25,"value":982},{"type":16,"tag":174,"props":1889,"children":1890},{"style":187},[1891],{"type":25,"value":1892}," 0",{"type":16,"tag":174,"props":1894,"children":1895},{"style":203},[1896],{"type":25,"value":992},{"type":16,"tag":174,"props":1898,"children":1899},{"style":181},[1900],{"type":25,"value":1862},{"type":16,"tag":174,"props":1902,"children":1903},{"style":220},[1904],{"type":25,"value":1905}," '0'",{"type":16,"tag":174,"props":1907,"children":1908},{"style":203},[1909],{"type":25,"value":905},{"type":16,"tag":174,"props":1911,"children":1912},{"class":176,"line":264},[1913],{"type":16,"tag":174,"props":1914,"children":1915},{"emptyLinePlaceholder":277},[1916],{"type":25,"value":280},{"type":16,"tag":174,"props":1918,"children":1919},{"class":176,"line":273},[1920],{"type":16,"tag":174,"props":1921,"children":1922},{"style":311},[1923],{"type":25,"value":1924},"  // Decide on the rounded value, so 999,999 at 3 digits becomes 1.00 × 10⁶, not \"1,000,000\"\n",{"type":16,"tag":174,"props":1926,"children":1927},{"class":176,"line":283},[1928,1932,1937,1941,1946,1951,1955,1959,1964,1969],{"type":16,"tag":174,"props":1929,"children":1930},{"style":181},[1931],{"type":25,"value":792},{"type":16,"tag":174,"props":1933,"children":1934},{"style":187},[1935],{"type":25,"value":1936}," rounded",{"type":16,"tag":174,"props":1938,"children":1939},{"style":181},[1940],{"type":25,"value":195},{"type":16,"tag":174,"props":1942,"children":1943},{"style":203},[1944],{"type":25,"value":1945}," Math.",{"type":16,"tag":174,"props":1947,"children":1948},{"style":209},[1949],{"type":25,"value":1950},"abs",{"type":16,"tag":174,"props":1952,"children":1953},{"style":203},[1954],{"type":25,"value":217},{"type":16,"tag":174,"props":1956,"children":1957},{"style":209},[1958],{"type":25,"value":1105},{"type":16,"tag":174,"props":1960,"children":1961},{"style":203},[1962],{"type":25,"value":1963},"(value.",{"type":16,"tag":174,"props":1965,"children":1966},{"style":209},[1967],{"type":25,"value":1968},"toPrecision",{"type":16,"tag":174,"props":1970,"children":1971},{"style":203},[1972],{"type":25,"value":1973},"(digits)));\n",{"type":16,"tag":174,"props":1975,"children":1976},{"class":176,"line":441},[1977,1981,1986,1991,1996,2001,2006,2011,2016,2020,2024],{"type":16,"tag":174,"props":1978,"children":1979},{"style":181},[1980],{"type":25,"value":1833},{"type":16,"tag":174,"props":1982,"children":1983},{"style":203},[1984],{"type":25,"value":1985}," (rounded ",{"type":16,"tag":174,"props":1987,"children":1988},{"style":181},[1989],{"type":25,"value":1990},"\u003C",{"type":16,"tag":174,"props":1992,"children":1993},{"style":203},[1994],{"type":25,"value":1995}," min ",{"type":16,"tag":174,"props":1997,"children":1998},{"style":181},[1999],{"type":25,"value":2000},"||",{"type":16,"tag":174,"props":2002,"children":2003},{"style":203},[2004],{"type":25,"value":2005}," rounded ",{"type":16,"tag":174,"props":2007,"children":2008},{"style":181},[2009],{"type":25,"value":2010},">=",{"type":16,"tag":174,"props":2012,"children":2013},{"style":203},[2014],{"type":25,"value":2015}," max) ",{"type":16,"tag":174,"props":2017,"children":2018},{"style":181},[2019],{"type":25,"value":1862},{"type":16,"tag":174,"props":2021,"children":2022},{"style":209},[2023],{"type":25,"value":1140},{"type":16,"tag":174,"props":2025,"children":2026},{"style":203},[2027],{"type":25,"value":2028},"(value, digits);\n",{"type":16,"tag":174,"props":2030,"children":2031},{"class":176,"line":450},[2032],{"type":16,"tag":174,"props":2033,"children":2034},{"emptyLinePlaceholder":277},[2035],{"type":25,"value":280},{"type":16,"tag":174,"props":2037,"children":2038},{"class":176,"line":459},[2039,2043,2047,2051,2055,2059,2063],{"type":16,"tag":174,"props":2040,"children":2041},{"style":181},[2042],{"type":25,"value":1095},{"type":16,"tag":174,"props":2044,"children":2045},{"style":181},[2046],{"type":25,"value":200},{"type":16,"tag":174,"props":2048,"children":2049},{"style":203},[2050],{"type":25,"value":206},{"type":16,"tag":174,"props":2052,"children":2053},{"style":209},[2054],{"type":25,"value":212},{"type":16,"tag":174,"props":2056,"children":2057},{"style":203},[2058],{"type":25,"value":217},{"type":16,"tag":174,"props":2060,"children":2061},{"style":220},[2062],{"type":25,"value":223},{"type":16,"tag":174,"props":2064,"children":2065},{"style":203},[2066],{"type":25,"value":228},{"type":16,"tag":174,"props":2068,"children":2069},{"class":176,"line":468},[2070],{"type":16,"tag":174,"props":2071,"children":2072},{"style":203},[2073],{"type":25,"value":841},{"type":16,"tag":174,"props":2075,"children":2076},{"class":176,"line":844},[2077],{"type":16,"tag":174,"props":2078,"children":2079},{"style":203},[2080],{"type":25,"value":850},{"type":16,"tag":174,"props":2082,"children":2083},{"class":176,"line":853},[2084,2088,2092],{"type":16,"tag":174,"props":2085,"children":2086},{"style":203},[2087],{"type":25,"value":859},{"type":16,"tag":174,"props":2089,"children":2090},{"style":209},[2091],{"type":25,"value":294},{"type":16,"tag":174,"props":2093,"children":2094},{"style":203},[2095],{"type":25,"value":868},{"type":16,"tag":174,"props":2097,"children":2098},{"class":176,"line":871},[2099],{"type":16,"tag":174,"props":2100,"children":2101},{"style":203},[2102],{"type":25,"value":1119},{"type":16,"tag":174,"props":2104,"children":2105},{"class":176,"line":879},[2106],{"type":16,"tag":174,"props":2107,"children":2108},{"emptyLinePlaceholder":277},[2109],{"type":25,"value":280},{"type":16,"tag":174,"props":2111,"children":2112},{"class":176,"line":908},[2113,2118,2122,2127,2132],{"type":16,"tag":174,"props":2114,"children":2115},{"style":209},[2116],{"type":25,"value":2117},"formatValue",{"type":16,"tag":174,"props":2119,"children":2120},{"style":203},[2121],{"type":25,"value":217},{"type":16,"tag":174,"props":2123,"children":2124},{"style":187},[2125],{"type":25,"value":2126},"0.0042",{"type":16,"tag":174,"props":2128,"children":2129},{"style":203},[2130],{"type":25,"value":2131},");     ",{"type":16,"tag":174,"props":2133,"children":2134},{"style":311},[2135],{"type":25,"value":2136},"// \"0.00420\"\n",{"type":16,"tag":174,"props":2138,"children":2139},{"class":176,"line":933},[2140,2144,2148,2153,2157],{"type":16,"tag":174,"props":2141,"children":2142},{"style":209},[2143],{"type":25,"value":2117},{"type":16,"tag":174,"props":2145,"children":2146},{"style":203},[2147],{"type":25,"value":217},{"type":16,"tag":174,"props":2149,"children":2150},{"style":187},[2151],{"type":25,"value":2152},"0.00042",{"type":16,"tag":174,"props":2154,"children":2155},{"style":203},[2156],{"type":25,"value":1380},{"type":16,"tag":174,"props":2158,"children":2159},{"style":311},[2160],{"type":25,"value":2161},"// \"4.20 × 10⁻⁴\"\n",{"type":16,"tag":174,"props":2163,"children":2164},{"class":176,"line":966},[2165,2169,2173,2178,2182],{"type":16,"tag":174,"props":2166,"children":2167},{"style":209},[2168],{"type":25,"value":2117},{"type":16,"tag":174,"props":2170,"children":2171},{"style":203},[2172],{"type":25,"value":217},{"type":16,"tag":174,"props":2174,"children":2175},{"style":187},[2176],{"type":25,"value":2177},"123.456",{"type":16,"tag":174,"props":2179,"children":2180},{"style":203},[2181],{"type":25,"value":1380},{"type":16,"tag":174,"props":2183,"children":2184},{"style":311},[2185],{"type":25,"value":2186},"// \"123\"\n",{"type":16,"tag":174,"props":2188,"children":2189},{"class":176,"line":1004},[2190,2194,2198,2203,2207],{"type":16,"tag":174,"props":2191,"children":2192},{"style":209},[2193],{"type":25,"value":2117},{"type":16,"tag":174,"props":2195,"children":2196},{"style":203},[2197],{"type":25,"value":217},{"type":16,"tag":174,"props":2199,"children":2200},{"style":187},[2201],{"type":25,"value":2202},"999999",{"type":16,"tag":174,"props":2204,"children":2205},{"style":203},[2206],{"type":25,"value":2131},{"type":16,"tag":174,"props":2208,"children":2209},{"style":311},[2210],{"type":25,"value":2211},"// \"1.00 × 10⁶\"\n",{"type":16,"tag":174,"props":2213,"children":2214},{"class":176,"line":1059},[2215,2219,2223,2228,2233],{"type":16,"tag":174,"props":2216,"children":2217},{"style":209},[2218],{"type":25,"value":2117},{"type":16,"tag":174,"props":2220,"children":2221},{"style":203},[2222],{"type":25,"value":217},{"type":16,"tag":174,"props":2224,"children":2225},{"style":187},[2226],{"type":25,"value":2227},"NaN",{"type":16,"tag":174,"props":2229,"children":2230},{"style":203},[2231],{"type":25,"value":2232},");        ",{"type":16,"tag":174,"props":2234,"children":2235},{"style":311},[2236],{"type":25,"value":2237},"// \"—\"\n",{"type":16,"tag":316,"props":2239,"children":2240},{},[2241],{"type":16,"tag":21,"props":2242,"children":2243},{},[2244,2246,2251,2253,2259,2261,2266,2267,2273],{"type":25,"value":2245},"The rounding check is the easy part to get wrong. ",{"type":16,"tag":11,"props":2247,"children":2249},{"className":2248},[],[2250],{"type":25,"value":2202},{"type":25,"value":2252}," is below one million, but rounded to three significant figures it displays as ",{"type":16,"tag":11,"props":2254,"children":2256},{"className":2255},[],[2257],{"type":25,"value":2258},"1,000,000",{"type":25,"value":2260},", exactly the kind of long number the threshold exists to avoid. Checking the rounded value fixes it. ",{"type":16,"tag":11,"props":2262,"children":2264},{"className":2263},[],[2265],{"type":25,"value":2227},{"type":25,"value":1456},{"type":16,"tag":11,"props":2268,"children":2270},{"className":2269},[],[2271],{"type":25,"value":2272},"Infinity",{"type":25,"value":2274}," show a dash instead of leaking into the UI.",{"type":16,"tag":151,"props":2276,"children":2277},{},[2278],{"type":16,"tag":21,"props":2279,"children":2280},{},[2281],{"type":25,"value":2282},"SI prefixes: 12.3 µA instead of 0.0000123 A",{"type":16,"tag":36,"props":2284,"children":2285},{},[2286],{"type":16,"tag":21,"props":2287,"children":2288},{},[2289,2291,2297],{"type":25,"value":2290},"For values with units, prefixes like milli, micro, and kilo are often clearer than any exponent. ",{"type":16,"tag":11,"props":2292,"children":2294},{"className":2293},[],[2295],{"type":25,"value":2296},"notation: 'engineering'",{"type":25,"value":2298}," is the key: it's scientific notation with the exponent always a multiple of 3, which is exactly what SI prefixes are.",{"type":16,"tag":160,"props":2300,"children":2301},{},[2302],{"type":16,"tag":164,"props":2303,"children":2305},{"className":166,"code":2304,"language":168,"meta":7,"style":7},"const PREFIXES = { '-12': 'p', '-9': 'n', '-6': 'µ', '-3': 'm', '0': '', '3': 'k', '6': 'M', '9': 'G' };\n\nfunction formatWithUnit(value, unit, digits = 3) {\n  const { mantissa, exponent } = split(value, 'engineering', digits);\n  const prefix = PREFIXES[exponent];\n  // Outside p…G there's no prefix, so fall back to scientific notation\n  if (prefix === undefined) return `${toScientific(value, digits)} ${unit}`;\n  return `${mantissa} ${prefix}${unit}`;\n}\n\nformatWithUnit(0.0000123, 'A');  // \"12.3 µA\"\nformatWithUnit(0.042, 'A');      // \"42.0 mA\"\nformatWithUnit(101325, 'Pa');    // \"101 kPa\"\nformatWithUnit(999.96, 'Pa');    // \"1.00 kPa\"\nformatWithUnit(2.5e-15, 'mol');  // \"2.50 × 10⁻¹⁵ mol\"\n",[2306],{"type":16,"tag":11,"props":2307,"children":2308},{"__ignoreMap":7},[2309,2470,2477,2526,2574,2599,2607,2682,2723,2730,2737,2771,2805,2839,2872],{"type":16,"tag":174,"props":2310,"children":2311},{"class":176,"line":177},[2312,2316,2321,2325,2329,2334,2338,2343,2347,2352,2356,2361,2365,2370,2374,2379,2383,2388,2392,2397,2401,2406,2410,2414,2418,2422,2426,2431,2435,2439,2443,2448,2452,2456,2460,2465],{"type":16,"tag":174,"props":2313,"children":2314},{"style":181},[2315],{"type":25,"value":184},{"type":16,"tag":174,"props":2317,"children":2318},{"style":187},[2319],{"type":25,"value":2320}," PREFIXES",{"type":16,"tag":174,"props":2322,"children":2323},{"style":181},[2324],{"type":25,"value":195},{"type":16,"tag":174,"props":2326,"children":2327},{"style":203},[2328],{"type":25,"value":1182},{"type":16,"tag":174,"props":2330,"children":2331},{"style":220},[2332],{"type":25,"value":2333},"'-12'",{"type":16,"tag":174,"props":2335,"children":2336},{"style":203},[2337],{"type":25,"value":526},{"type":16,"tag":174,"props":2339,"children":2340},{"style":220},[2341],{"type":25,"value":2342},"'p'",{"type":16,"tag":174,"props":2344,"children":2345},{"style":203},[2346],{"type":25,"value":536},{"type":16,"tag":174,"props":2348,"children":2349},{"style":220},[2350],{"type":25,"value":2351},"'-9'",{"type":16,"tag":174,"props":2353,"children":2354},{"style":203},[2355],{"type":25,"value":526},{"type":16,"tag":174,"props":2357,"children":2358},{"style":220},[2359],{"type":25,"value":2360},"'n'",{"type":16,"tag":174,"props":2362,"children":2363},{"style":203},[2364],{"type":25,"value":536},{"type":16,"tag":174,"props":2366,"children":2367},{"style":220},[2368],{"type":25,"value":2369},"'-6'",{"type":16,"tag":174,"props":2371,"children":2372},{"style":203},[2373],{"type":25,"value":526},{"type":16,"tag":174,"props":2375,"children":2376},{"style":220},[2377],{"type":25,"value":2378},"'µ'",{"type":16,"tag":174,"props":2380,"children":2381},{"style":203},[2382],{"type":25,"value":536},{"type":16,"tag":174,"props":2384,"children":2385},{"style":220},[2386],{"type":25,"value":2387},"'-3'",{"type":16,"tag":174,"props":2389,"children":2390},{"style":203},[2391],{"type":25,"value":526},{"type":16,"tag":174,"props":2393,"children":2394},{"style":220},[2395],{"type":25,"value":2396},"'m'",{"type":16,"tag":174,"props":2398,"children":2399},{"style":203},[2400],{"type":25,"value":536},{"type":16,"tag":174,"props":2402,"children":2403},{"style":220},[2404],{"type":25,"value":2405},"'0'",{"type":16,"tag":174,"props":2407,"children":2408},{"style":203},[2409],{"type":25,"value":526},{"type":16,"tag":174,"props":2411,"children":2412},{"style":220},[2413],{"type":25,"value":1302},{"type":16,"tag":174,"props":2415,"children":2416},{"style":203},[2417],{"type":25,"value":536},{"type":16,"tag":174,"props":2419,"children":2420},{"style":220},[2421],{"type":25,"value":577},{"type":16,"tag":174,"props":2423,"children":2424},{"style":203},[2425],{"type":25,"value":526},{"type":16,"tag":174,"props":2427,"children":2428},{"style":220},[2429],{"type":25,"value":2430},"'k'",{"type":16,"tag":174,"props":2432,"children":2433},{"style":203},[2434],{"type":25,"value":536},{"type":16,"tag":174,"props":2436,"children":2437},{"style":220},[2438],{"type":25,"value":634},{"type":16,"tag":174,"props":2440,"children":2441},{"style":203},[2442],{"type":25,"value":526},{"type":16,"tag":174,"props":2444,"children":2445},{"style":220},[2446],{"type":25,"value":2447},"'M'",{"type":16,"tag":174,"props":2449,"children":2450},{"style":203},[2451],{"type":25,"value":536},{"type":16,"tag":174,"props":2453,"children":2454},{"style":220},[2455],{"type":25,"value":688},{"type":16,"tag":174,"props":2457,"children":2458},{"style":203},[2459],{"type":25,"value":526},{"type":16,"tag":174,"props":2461,"children":2462},{"style":220},[2463],{"type":25,"value":2464},"'G'",{"type":16,"tag":174,"props":2466,"children":2467},{"style":203},[2468],{"type":25,"value":2469}," };\n",{"type":16,"tag":174,"props":2471,"children":2472},{"class":176,"line":231},[2473],{"type":16,"tag":174,"props":2474,"children":2475},{"emptyLinePlaceholder":277},[2476],{"type":25,"value":280},{"type":16,"tag":174,"props":2478,"children":2479},{"class":176,"line":250},[2480,2484,2489,2493,2497,2501,2506,2510,2514,2518,2522],{"type":16,"tag":174,"props":2481,"children":2482},{"style":181},[2483],{"type":25,"value":746},{"type":16,"tag":174,"props":2485,"children":2486},{"style":209},[2487],{"type":25,"value":2488}," formatWithUnit",{"type":16,"tag":174,"props":2490,"children":2491},{"style":203},[2492],{"type":25,"value":217},{"type":16,"tag":174,"props":2494,"children":2495},{"style":758},[2496],{"type":25,"value":761},{"type":16,"tag":174,"props":2498,"children":2499},{"style":203},[2500],{"type":25,"value":536},{"type":16,"tag":174,"props":2502,"children":2503},{"style":758},[2504],{"type":25,"value":2505},"unit",{"type":16,"tag":174,"props":2507,"children":2508},{"style":203},[2509],{"type":25,"value":536},{"type":16,"tag":174,"props":2511,"children":2512},{"style":758},[2513],{"type":25,"value":779},{"type":16,"tag":174,"props":2515,"children":2516},{"style":181},[2517],{"type":25,"value":195},{"type":16,"tag":174,"props":2519,"children":2520},{"style":187},[2521],{"type":25,"value":1165},{"type":16,"tag":174,"props":2523,"children":2524},{"style":203},[2525],{"type":25,"value":784},{"type":16,"tag":174,"props":2527,"children":2528},{"class":176,"line":264},[2529,2533,2537,2541,2545,2549,2553,2557,2561,2565,2570],{"type":16,"tag":174,"props":2530,"children":2531},{"style":181},[2532],{"type":25,"value":792},{"type":16,"tag":174,"props":2534,"children":2535},{"style":203},[2536],{"type":25,"value":1182},{"type":16,"tag":174,"props":2538,"children":2539},{"style":187},[2540],{"type":25,"value":1187},{"type":16,"tag":174,"props":2542,"children":2543},{"style":203},[2544],{"type":25,"value":536},{"type":16,"tag":174,"props":2546,"children":2547},{"style":187},[2548],{"type":25,"value":1196},{"type":16,"tag":174,"props":2550,"children":2551},{"style":203},[2552],{"type":25,"value":1201},{"type":16,"tag":174,"props":2554,"children":2555},{"style":181},[2556],{"type":25,"value":895},{"type":16,"tag":174,"props":2558,"children":2559},{"style":209},[2560],{"type":25,"value":751},{"type":16,"tag":174,"props":2562,"children":2563},{"style":203},[2564],{"type":25,"value":1214},{"type":16,"tag":174,"props":2566,"children":2567},{"style":220},[2568],{"type":25,"value":2569},"'engineering'",{"type":16,"tag":174,"props":2571,"children":2572},{"style":203},[2573],{"type":25,"value":1223},{"type":16,"tag":174,"props":2575,"children":2576},{"class":176,"line":273},[2577,2581,2586,2590,2594],{"type":16,"tag":174,"props":2578,"children":2579},{"style":181},[2580],{"type":25,"value":792},{"type":16,"tag":174,"props":2582,"children":2583},{"style":187},[2584],{"type":25,"value":2585}," prefix",{"type":16,"tag":174,"props":2587,"children":2588},{"style":181},[2589],{"type":25,"value":195},{"type":16,"tag":174,"props":2591,"children":2592},{"style":187},[2593],{"type":25,"value":2320},{"type":16,"tag":174,"props":2595,"children":2596},{"style":203},[2597],{"type":25,"value":2598},"[exponent];\n",{"type":16,"tag":174,"props":2600,"children":2601},{"class":176,"line":283},[2602],{"type":16,"tag":174,"props":2603,"children":2604},{"style":311},[2605],{"type":25,"value":2606},"  // Outside p…G there's no prefix, so fall back to scientific notation\n",{"type":16,"tag":174,"props":2608,"children":2609},{"class":176,"line":441},[2610,2614,2619,2623,2628,2632,2636,2640,2644,2648,2652,2656,2660,2665,2670,2674,2678],{"type":16,"tag":174,"props":2611,"children":2612},{"style":181},[2613],{"type":25,"value":1833},{"type":16,"tag":174,"props":2615,"children":2616},{"style":203},[2617],{"type":25,"value":2618}," (prefix ",{"type":16,"tag":174,"props":2620,"children":2621},{"style":181},[2622],{"type":25,"value":982},{"type":16,"tag":174,"props":2624,"children":2625},{"style":187},[2626],{"type":25,"value":2627}," undefined",{"type":16,"tag":174,"props":2629,"children":2630},{"style":203},[2631],{"type":25,"value":992},{"type":16,"tag":174,"props":2633,"children":2634},{"style":181},[2635],{"type":25,"value":1862},{"type":16,"tag":174,"props":2637,"children":2638},{"style":220},[2639],{"type":25,"value":1319},{"type":16,"tag":174,"props":2641,"children":2642},{"style":209},[2643],{"type":25,"value":1367},{"type":16,"tag":174,"props":2645,"children":2646},{"style":220},[2647],{"type":25,"value":217},{"type":16,"tag":174,"props":2649,"children":2650},{"style":203},[2651],{"type":25,"value":761},{"type":16,"tag":174,"props":2653,"children":2654},{"style":220},[2655],{"type":25,"value":536},{"type":16,"tag":174,"props":2657,"children":2658},{"style":203},[2659],{"type":25,"value":779},{"type":16,"tag":174,"props":2661,"children":2662},{"style":220},[2663],{"type":25,"value":2664},")",{"type":16,"tag":174,"props":2666,"children":2667},{"style":220},[2668],{"type":25,"value":2669},"} ${",{"type":16,"tag":174,"props":2671,"children":2672},{"style":203},[2673],{"type":25,"value":2505},{"type":16,"tag":174,"props":2675,"children":2676},{"style":220},[2677],{"type":25,"value":1338},{"type":16,"tag":174,"props":2679,"children":2680},{"style":203},[2681],{"type":25,"value":905},{"type":16,"tag":174,"props":2683,"children":2684},{"class":176,"line":450},[2685,2689,2693,2697,2701,2706,2711,2715,2719],{"type":16,"tag":174,"props":2686,"children":2687},{"style":181},[2688],{"type":25,"value":1095},{"type":16,"tag":174,"props":2690,"children":2691},{"style":220},[2692],{"type":25,"value":1319},{"type":16,"tag":174,"props":2694,"children":2695},{"style":203},[2696],{"type":25,"value":1187},{"type":16,"tag":174,"props":2698,"children":2699},{"style":220},[2700],{"type":25,"value":2669},{"type":16,"tag":174,"props":2702,"children":2703},{"style":203},[2704],{"type":25,"value":2705},"prefix",{"type":16,"tag":174,"props":2707,"children":2708},{"style":220},[2709],{"type":25,"value":2710},"}${",{"type":16,"tag":174,"props":2712,"children":2713},{"style":203},[2714],{"type":25,"value":2505},{"type":16,"tag":174,"props":2716,"children":2717},{"style":220},[2718],{"type":25,"value":1338},{"type":16,"tag":174,"props":2720,"children":2721},{"style":203},[2722],{"type":25,"value":905},{"type":16,"tag":174,"props":2724,"children":2725},{"class":176,"line":459},[2726],{"type":16,"tag":174,"props":2727,"children":2728},{"style":203},[2729],{"type":25,"value":1119},{"type":16,"tag":174,"props":2731,"children":2732},{"class":176,"line":468},[2733],{"type":16,"tag":174,"props":2734,"children":2735},{"emptyLinePlaceholder":277},[2736],{"type":25,"value":280},{"type":16,"tag":174,"props":2738,"children":2739},{"class":176,"line":844},[2740,2745,2749,2753,2757,2762,2766],{"type":16,"tag":174,"props":2741,"children":2742},{"style":209},[2743],{"type":25,"value":2744},"formatWithUnit",{"type":16,"tag":174,"props":2746,"children":2747},{"style":203},[2748],{"type":25,"value":217},{"type":16,"tag":174,"props":2750,"children":2751},{"style":187},[2752],{"type":25,"value":49},{"type":16,"tag":174,"props":2754,"children":2755},{"style":203},[2756],{"type":25,"value":536},{"type":16,"tag":174,"props":2758,"children":2759},{"style":220},[2760],{"type":25,"value":2761},"'A'",{"type":16,"tag":174,"props":2763,"children":2764},{"style":203},[2765],{"type":25,"value":308},{"type":16,"tag":174,"props":2767,"children":2768},{"style":311},[2769],{"type":25,"value":2770},"// \"12.3 µA\"\n",{"type":16,"tag":174,"props":2772,"children":2773},{"class":176,"line":853},[2774,2778,2782,2787,2791,2795,2800],{"type":16,"tag":174,"props":2775,"children":2776},{"style":209},[2777],{"type":25,"value":2744},{"type":16,"tag":174,"props":2779,"children":2780},{"style":203},[2781],{"type":25,"value":217},{"type":16,"tag":174,"props":2783,"children":2784},{"style":187},[2785],{"type":25,"value":2786},"0.042",{"type":16,"tag":174,"props":2788,"children":2789},{"style":203},[2790],{"type":25,"value":536},{"type":16,"tag":174,"props":2792,"children":2793},{"style":220},[2794],{"type":25,"value":2761},{"type":16,"tag":174,"props":2796,"children":2797},{"style":203},[2798],{"type":25,"value":2799},");      ",{"type":16,"tag":174,"props":2801,"children":2802},{"style":311},[2803],{"type":25,"value":2804},"// \"42.0 mA\"\n",{"type":16,"tag":174,"props":2806,"children":2807},{"class":176,"line":871},[2808,2812,2816,2821,2825,2830,2834],{"type":16,"tag":174,"props":2809,"children":2810},{"style":209},[2811],{"type":25,"value":2744},{"type":16,"tag":174,"props":2813,"children":2814},{"style":203},[2815],{"type":25,"value":217},{"type":16,"tag":174,"props":2817,"children":2818},{"style":187},[2819],{"type":25,"value":2820},"101325",{"type":16,"tag":174,"props":2822,"children":2823},{"style":203},[2824],{"type":25,"value":536},{"type":16,"tag":174,"props":2826,"children":2827},{"style":220},[2828],{"type":25,"value":2829},"'Pa'",{"type":16,"tag":174,"props":2831,"children":2832},{"style":203},[2833],{"type":25,"value":1380},{"type":16,"tag":174,"props":2835,"children":2836},{"style":311},[2837],{"type":25,"value":2838},"// \"101 kPa\"\n",{"type":16,"tag":174,"props":2840,"children":2841},{"class":176,"line":879},[2842,2846,2850,2855,2859,2863,2867],{"type":16,"tag":174,"props":2843,"children":2844},{"style":209},[2845],{"type":25,"value":2744},{"type":16,"tag":174,"props":2847,"children":2848},{"style":203},[2849],{"type":25,"value":217},{"type":16,"tag":174,"props":2851,"children":2852},{"style":187},[2853],{"type":25,"value":2854},"999.96",{"type":16,"tag":174,"props":2856,"children":2857},{"style":203},[2858],{"type":25,"value":536},{"type":16,"tag":174,"props":2860,"children":2861},{"style":220},[2862],{"type":25,"value":2829},{"type":16,"tag":174,"props":2864,"children":2865},{"style":203},[2866],{"type":25,"value":1380},{"type":16,"tag":174,"props":2868,"children":2869},{"style":311},[2870],{"type":25,"value":2871},"// \"1.00 kPa\"\n",{"type":16,"tag":174,"props":2873,"children":2874},{"class":176,"line":908},[2875,2879,2883,2888,2892,2897,2901],{"type":16,"tag":174,"props":2876,"children":2877},{"style":209},[2878],{"type":25,"value":2744},{"type":16,"tag":174,"props":2880,"children":2881},{"style":203},[2882],{"type":25,"value":217},{"type":16,"tag":174,"props":2884,"children":2885},{"style":187},[2886],{"type":25,"value":2887},"2.5e-15",{"type":16,"tag":174,"props":2889,"children":2890},{"style":203},[2891],{"type":25,"value":536},{"type":16,"tag":174,"props":2893,"children":2894},{"style":220},[2895],{"type":25,"value":2896},"'mol'",{"type":16,"tag":174,"props":2898,"children":2899},{"style":203},[2900],{"type":25,"value":308},{"type":16,"tag":174,"props":2902,"children":2903},{"style":311},[2904],{"type":25,"value":2905},"// \"2.50 × 10⁻¹⁵ mol\"\n",{"type":16,"tag":316,"props":2907,"children":2908},{},[2909],{"type":16,"tag":21,"props":2910,"children":2911},{},[2912,2914,2920,2922,2928,2930,2936,2938,2944],{"type":25,"value":2913},"Intl rounds before it picks the exponent, so ",{"type":16,"tag":11,"props":2915,"children":2917},{"className":2916},[],[2918],{"type":25,"value":2919},"999.96 Pa",{"type":25,"value":2921}," correctly becomes ",{"type":16,"tag":11,"props":2923,"children":2925},{"className":2924},[],[2926],{"type":25,"value":2927},"1.00 kPa",{"type":25,"value":2929}," and not ",{"type":16,"tag":11,"props":2931,"children":2933},{"className":2932},[],[2934],{"type":25,"value":2935},"1000 Pa",{"type":25,"value":2937},". ",{"type":16,"tag":11,"props":2939,"children":2941},{"className":2940},[],[2942],{"type":25,"value":2943}," ",{"type":25,"value":2945}," is a non-breaking space, so a value never wraps onto a different line from its unit.",{"type":16,"tag":151,"props":2947,"children":2948},{},[2949],{"type":16,"tag":21,"props":2950,"children":2951},{},[2952],{"type":25,"value":2953},"Why not Intl's unit style?",{"type":16,"tag":36,"props":2955,"children":2956},{},[2957],{"type":16,"tag":21,"props":2958,"children":2959},{},[2960,2965,2967,2973,2975,2981,2983,2989,2991,2997,2999,3005,3007,3013],{"type":16,"tag":11,"props":2961,"children":2963},{"className":2962},[],[2964],{"type":25,"value":147},{"type":25,"value":2966}," has ",{"type":16,"tag":11,"props":2968,"children":2970},{"className":2969},[],[2971],{"type":25,"value":2972},"style: 'unit'",{"type":25,"value":2974},", and it's great for everyday units: ",{"type":16,"tag":11,"props":2976,"children":2978},{"className":2977},[],[2979],{"type":25,"value":2980},"{ style: 'unit', unit: 'celsius' }",{"type":25,"value":2982}," formats ",{"type":16,"tag":11,"props":2984,"children":2986},{"className":2985},[],[2987],{"type":25,"value":2988},"21.5",{"type":25,"value":2990}," as ",{"type":16,"tag":11,"props":2992,"children":2994},{"className":2993},[],[2995],{"type":25,"value":2996},"21.5°C",{"type":25,"value":2998},". But it only supports a fixed list of units, and most scientific ones aren't on it. ",{"type":16,"tag":11,"props":3000,"children":3002},{"className":3001},[],[3003],{"type":25,"value":3004},"unit: 'pascal'",{"type":25,"value":3006}," throws a ",{"type":16,"tag":11,"props":3008,"children":3010},{"className":3009},[],[3011],{"type":25,"value":3012},"RangeError",{"type":25,"value":3014},". For anything beyond everyday units, appending the unit yourself is the practical option.",{"type":16,"tag":151,"props":3016,"children":3017},{},[3018],{"type":16,"tag":21,"props":3019,"children":3020},{},[3021],{"type":25,"value":3022},"Lessons learned",{"type":16,"tag":84,"props":3024,"children":3025},{},[3026],{"type":16,"tag":88,"props":3027,"children":3028},{},[3029,3046,3069,3079,3089],{"type":16,"tag":92,"props":3030,"children":3031},{},[3032,3037,3039,3044],{"type":16,"tag":96,"props":3033,"children":3034},{},[3035],{"type":25,"value":3036},"Let Intl do the math.",{"type":25,"value":3038}," Rounding and exponent selection are easy to get subtly wrong by hand. ",{"type":16,"tag":11,"props":3040,"children":3042},{"className":3041},[],[3043],{"type":25,"value":357},{"type":25,"value":3045}," lets you change the look without redoing the math.",{"type":16,"tag":92,"props":3047,"children":3048},{},[3049,3054,3056,3061,3063,3068],{"type":16,"tag":96,"props":3050,"children":3051},{},[3052],{"type":25,"value":3053},"Precision is information.",{"type":25,"value":3055}," Set both minimum and maximum significant digits, so ",{"type":16,"tag":11,"props":3057,"children":3059},{"className":3058},[],[3060],{"type":25,"value":110},{"type":25,"value":3062}," doesn't become ",{"type":16,"tag":11,"props":3064,"children":3066},{"className":3065},[],[3067],{"type":25,"value":117},{"type":25,"value":345},{"type":16,"tag":92,"props":3070,"children":3071},{},[3072,3077],{"type":16,"tag":96,"props":3073,"children":3074},{},[3075],{"type":25,"value":3076},"Decide on what users will see.",{"type":25,"value":3078}," Thresholds should check the rounded value, not the raw one.",{"type":16,"tag":92,"props":3080,"children":3081},{},[3082,3087],{"type":16,"tag":96,"props":3083,"children":3084},{},[3085],{"type":25,"value":3086},"Engineering notation maps to SI prefixes.",{"type":25,"value":3088}," Exponents in multiples of 3 turn into milli, micro, and kilo with a lookup table.",{"type":16,"tag":92,"props":3090,"children":3091},{},[3092,3097,3099,3104,3105,3110],{"type":16,"tag":96,"props":3093,"children":3094},{},[3095],{"type":25,"value":3096},"Handle the edges.",{"type":25,"value":3098}," Zero, ",{"type":16,"tag":11,"props":3100,"children":3102},{"className":3101},[],[3103],{"type":25,"value":2227},{"type":25,"value":536},{"type":16,"tag":11,"props":3106,"children":3108},{"className":3107},[],[3109],{"type":25,"value":2272},{"type":25,"value":3111},", and values beyond the prefix range all need an answer.",{"type":16,"tag":151,"props":3113,"children":3114},{},[3115],{"type":16,"tag":21,"props":3116,"children":3117},{},[3118],{"type":25,"value":3119},"Conclusion",{"type":16,"tag":36,"props":3121,"children":3122},{},[3123],{"type":16,"tag":21,"props":3124,"children":3125},{},[3126,3128,3133],{"type":25,"value":3127},"Three small functions on top of ",{"type":16,"tag":11,"props":3129,"children":3131},{"className":3130},[],[3132],{"type":25,"value":147},{"type":25,"value":3134}," cover most of what a scientific dashboard needs: readable exponents, honest precision, and proper SI units. They're plain JavaScript, so they work the same in a Vue template, a chart tooltip, or a CSV export.",{"type":16,"tag":36,"props":3136,"children":3137},{},[3138],{"type":16,"tag":21,"props":3139,"children":3140},{},[3141,3143,3147],{"type":25,"value":3142},"Let me know if you found this useful. Feel free to reach out to me with any questions on ",{"type":16,"tag":3144,"props":3145,"children":3146},"linkedin-link",{},[],{"type":25,"value":345},{"type":16,"tag":3149,"props":3150,"children":3151},"style",{},[3152],{"type":25,"value":3153},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":231,"depth":231,"links":3155},[],"markdown","content:blog:formatting-scientific-values.md","content","blog/formatting-scientific-values.md","blog/formatting-scientific-values","md",{"loc":4},1796288161051]