[{"data":1,"prerenderedAt":297},["ShallowReactive",2],{"term-f\u002Ffloat":3,"related-f\u002Ffloat":281},{"id":4,"title":5,"acronym":6,"body":7,"category":262,"description":263,"difficulty":264,"extension":265,"letter":266,"meta":267,"navigation":121,"path":268,"related":269,"seo":275,"sitemap":276,"stem":279,"subcategory":6,"__hash__":280},"terms\u002Fterms\u002Ff\u002Ffloat.md","Float",null,{"type":8,"value":9,"toc":256},"minimark",[10,15,19,23,26,30,245,249,252],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 — The Vibe Check",[16,17,18],"p",{},"A float is a number with a decimal point — 3.14, 1.5, -0.001. The name comes from 'floating point' because the decimal point can be anywhere. The tricky thing: computers cannot store ALL decimals exactly, so 0.1 + 0.2 does not always equal exactly 0.3. This surprises every beginner programmer.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"A floating-point number (float) is a numeric type that represents real numbers with fractional components using the IEEE 754 standard. Single precision (float32) uses 32 bits; double precision (float64) uses 64 bits. Floating-point arithmetic has inherent precision limitations — not all decimals can be represented exactly in binary, causing rounding errors. Never use floats for money — use integers (cents) instead.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F The classic floating point surprise:\nconsole.log(0.1 + 0.2);         \u002F\u002F 0.30000000000000004\nconsole.log(0.1 + 0.2 === 0.3); \u002F\u002F false!\n\n\u002F\u002F Why? Binary can't represent 0.1 exactly\n\u002F\u002F Fix with epsilon comparison:\nconst isEqual = Math.abs(0.1 + 0.2 - 0.3) \u003C Number.EPSILON;\n\n\u002F\u002F Money: NEVER use floats\n\u002F\u002F BAD:\nconst price = 19.99; \u002F\u002F might lose cents\n\u002F\u002F GOOD:\nconst priceInCents = 1999; \u002F\u002F integers are exact\n","javascript","",[38,39,40,49,86,116,123,129,135,186,191,197,203,221,227],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,48],{"class":47},"sHwdD","\u002F\u002F The classic floating point surprise:\n",[41,50,52,56,60,64,67,71,74,77,80,83],{"class":43,"line":51},2,[41,53,55],{"class":54},"sTEyZ","console",[41,57,59],{"class":58},"sMK4o",".",[41,61,63],{"class":62},"s2Zo4","log",[41,65,66],{"class":54},"(",[41,68,70],{"class":69},"sbssI","0.1",[41,72,73],{"class":58}," +",[41,75,76],{"class":69}," 0.2",[41,78,79],{"class":54},")",[41,81,82],{"class":58},";",[41,84,85],{"class":47},"         \u002F\u002F 0.30000000000000004\n",[41,87,89,91,93,95,97,99,101,103,106,109,111,113],{"class":43,"line":88},3,[41,90,55],{"class":54},[41,92,59],{"class":58},[41,94,63],{"class":62},[41,96,66],{"class":54},[41,98,70],{"class":69},[41,100,73],{"class":58},[41,102,76],{"class":69},[41,104,105],{"class":58}," ===",[41,107,108],{"class":69}," 0.3",[41,110,79],{"class":54},[41,112,82],{"class":58},[41,114,115],{"class":47}," \u002F\u002F false!\n",[41,117,119],{"class":43,"line":118},4,[41,120,122],{"emptyLinePlaceholder":121},true,"\n",[41,124,126],{"class":43,"line":125},5,[41,127,128],{"class":47},"\u002F\u002F Why? Binary can't represent 0.1 exactly\n",[41,130,132],{"class":43,"line":131},6,[41,133,134],{"class":47},"\u002F\u002F Fix with epsilon comparison:\n",[41,136,138,142,145,148,151,153,156,158,160,162,164,167,169,172,175,178,180,183],{"class":43,"line":137},7,[41,139,141],{"class":140},"spNyl","const",[41,143,144],{"class":54}," isEqual ",[41,146,147],{"class":58},"=",[41,149,150],{"class":54}," Math",[41,152,59],{"class":58},[41,154,155],{"class":62},"abs",[41,157,66],{"class":54},[41,159,70],{"class":69},[41,161,73],{"class":58},[41,163,76],{"class":69},[41,165,166],{"class":58}," -",[41,168,108],{"class":69},[41,170,171],{"class":54},") ",[41,173,174],{"class":58},"\u003C",[41,176,177],{"class":54}," Number",[41,179,59],{"class":58},[41,181,182],{"class":54},"EPSILON",[41,184,185],{"class":58},";\n",[41,187,189],{"class":43,"line":188},8,[41,190,122],{"emptyLinePlaceholder":121},[41,192,194],{"class":43,"line":193},9,[41,195,196],{"class":47},"\u002F\u002F Money: NEVER use floats\n",[41,198,200],{"class":43,"line":199},10,[41,201,202],{"class":47},"\u002F\u002F BAD:\n",[41,204,206,208,211,213,216,218],{"class":43,"line":205},11,[41,207,141],{"class":140},[41,209,210],{"class":54}," price ",[41,212,147],{"class":58},[41,214,215],{"class":69}," 19.99",[41,217,82],{"class":58},[41,219,220],{"class":47}," \u002F\u002F might lose cents\n",[41,222,224],{"class":43,"line":223},12,[41,225,226],{"class":47},"\u002F\u002F GOOD:\n",[41,228,230,232,235,237,240,242],{"class":43,"line":229},13,[41,231,141],{"class":140},[41,233,234],{"class":54}," priceInCents ",[41,236,147],{"class":58},[41,238,239],{"class":69}," 1999",[41,241,82],{"class":58},[41,243,244],{"class":47}," \u002F\u002F integers are exact\n",[11,246,248],{"id":247},"when-youll-hear-this","When You'll Hear This",[16,250,251],{},"\"Use integers for money, not floats — floating point errors will bite you.\" \u002F \"The 0.1 + 0.2 bug is a classic float precision issue.\"",[253,254,255],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}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);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":51,"depth":51,"links":257},[258,259,260,261],{"id":13,"depth":51,"text":14},{"id":21,"depth":51,"text":22},{"id":28,"depth":51,"text":29},{"id":247,"depth":51,"text":248},"general","A float is a number with a decimal point — 3.14, 1.5, -0.001. The name comes from 'floating point' because the decimal point can be anywhere.","beginner","md","f",{},"\u002Fterms\u002Ff\u002Ffloat",[270,271,272,273,274],"Integer","Number","Type","NaN","Precision",{"title":5,"description":263},{"changefreq":277,"priority":278},"weekly",0.7,"terms\u002Ff\u002Ffloat","aOjpo86FXIVUa1S-lrwKG8pC63v3jxQaf-s2pTaPmp8",[282,285,289,294],{"title":270,"path":283,"acronym":6,"category":262,"difficulty":264,"description":284},"\u002Fterms\u002Fi\u002Finteger","An integer is a whole number — no decimal point. 1, 42, -7, 1000 are integers. 1.5 is NOT an integer, that is a float.",{"title":273,"path":286,"acronym":287,"category":262,"difficulty":264,"description":288},"\u002Fterms\u002Fn\u002Fnan","Not a Number","NaN means 'Not a Number' — it is what JavaScript gives you when math goes wrong in a weird way. Try to parse a word as a number and you get NaN.",{"title":274,"path":290,"acronym":6,"category":291,"difficulty":292,"description":293},"\u002Fterms\u002Fp\u002Fprecision","ai","intermediate","Precision asks: 'Of all the times the AI said YES, how often was it actually right?",{"title":272,"path":295,"acronym":6,"category":262,"difficulty":264,"description":296},"\u002Fterms\u002Ft\u002Ftype","A type tells the computer what kind of thing a value is — is it a number, text, true\u002Ffalse, or a list?",1776518280611]