Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JavaScript float precision 2

<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Numbers</h1>
<h2>The toPrecision() Method</h2>

<p>toPrecision() formats a number to a specified length:</p>

<p id="demo"></p>

<script>
let num = 0.001658853;

document.getElementById("demo").innerHTML =
num.toPrecision(2) + "<br>" +
num.toPrecision(3) + "<br>" +
num.toPrecision(10);
</script>

</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: @editorjs/list window not defined 
Javascript :: javascript rectangle collision 
Javascript :: calculate distance between two coordinates formula javascript 
Javascript :: react-native-youtube-iframe android crash 
Javascript :: can we use two versions of jquery in same page 
Javascript :: check if an HTML element has any children 
Javascript :: how to save data i mongi db 
Javascript :: js create script tag request 
Javascript :: adonis join condition 
Javascript :: nodejs error _.isNull is not a function 
Javascript :: scss mute warnings 
Javascript :: setattribute disabled javascript 
Javascript :: convert text to binary javascript 
Javascript :: js get first 3 characters of string 
Javascript :: simple AES encryption javascript 
Javascript :: moment string to date convert node js 
Javascript :: single quote error in react prettier 
Javascript :: Error: open failed: EACCES (Permission denied) react native 
Javascript :: 11.10*15.1667 
Javascript :: sort and split js alefbethic 
Javascript :: switch c++ 
Javascript :: emmet react self closing tags 
Javascript :: javascript tofixed only if decimal 
Javascript :: input javascript console 
Javascript :: how to give a label padding through jquery 
Javascript :: js get all object styles 
Javascript :: current datetime js 
Javascript :: change value krajee star rating using jquery 
Javascript :: delete duplicates array of strings Javascript 
Javascript :: quicksettins.js 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =