javascript remove scientific notation
function toFixed(x) {
if (Math.abs(x) < 1.0) {
var e = parseInt(x.toString().split('e-')[1]);
if (e) {
x *= Math.pow(10,e-1);
x = '0.' + (new Array(e)).join('0') + x.toString().substring(2);
}
} else {
var e = parseInt(x.toString().split('+')[1]);
if (e > 20) {
e -= 20;
x /= Math.pow(10,e);
x += (new Array(e+1)).join('0');
}
}
return x;
}
function toFixed(x) {
if (Math.abs(x) < 1.0) {
var e = parseInt(x.toString().split('e-')[1]);
if (e) {
x *= Math.pow(10,e-1);
x = '0.' + (new Array(e)).join('0') + x.toString().substring(2);
}
} else {
var e = parseInt(x.toString().split('+')[1]);
if (e > 20) {
e -= 20;
x /= Math.pow(10,e);
x += (new Array(e+1)).join('0');
}
}
return x;
}
Also in JavaScript:
- death calculator by date of birth make in java
- convert date to string javascript
- remove first char javascript
- javascript ajax post send an object
- expressjs cheat sheet
- js array map skip element
- get id of clicked element javascript
- railsparse json to object
- how to send message to specific client using ws node js
- arrow keys function javascript
- add class to html tag javascript
- how to edit the visibiility of an element javscript
- how to get csrf token in javascript
- how to get element by attribute value in javascript
- character to ascii in js
- javascript path folder above
- moment js year only
- array in javascript
- Javascript check if undefined
- enzyme hasclass example
- index and id together angularjs
- ts-node command not found
- react function called last state
- javascript remove final newline from string