---
title: "What is float precision in JavaScript?"  
description: "What is float precision in JavaScript?"  
author: "Ashutosh Patel"  
published: 2024-12-22  
updated: 2024-12-28  
canonical: https://www.mindstick.com/forum/161073/what-is-float-precision-in-javascript  
category: "javascript"  
tags: ["javascript", "scripting"]  
reading_time: 1 minute  

---

# What is float precision in JavaScript?

What is [float](https://www.mindstick.com/interview/1718/describe-float-containment) precision in [JavaScript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript)?

## Replies

### Reply by Khushi Singh

Precision in JavaScript relating to floating point refers to how accurate the decimal numbers are handled. JavaScript stores numbers as the 64 floating point format compliant with IEEE 754 standard, which causes precise arithmetic errors if decimals are used.

```javascript
console.log(0.1 + 0.2); // Outputs: 0.30000000000000004

```

This occurs due to a phenomenon, where, not all decimal fractions can be accurately approximated when converted to binary representation which is used internally. To handle such cases, you can use methods like toFixed() or toPrecision() to control the number of decimal places:\

```javascript
console.log((0.1 + 0.2).toFixed(2)); // Outputs: "0.30"
```

If you'd like to dive deeper into JavaScript concepts, [here is our guide](https://www.mindstick.com/articles/279873/learn-javascript-faster-tips-and-advice-for-beginners)

\


---

Original Source: https://www.mindstick.com/forum/161073/what-is-float-precision-in-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
