In an HTML page, I want the output of my decimal numbers to have only two positions instead of three - Example: 13.16
and not 13.167
.
But it is not working when I try to set it. How can I do this using the code below?
currentJobStatus.push(
cncActiveState[0].totaltime * 100 /
Number(stdcycletime[0].Standard_Cycle_Time)
).toFixed(1);
I have tried using toFixed(1)
function, but it is not working.
Here is my node.js code :
currentJobStatus.push(
cncActiveState[0].totaltime * 100 /
Number(stdcycletime[0].Standard_Cycle_Time)
).toFixed(1);
Here is my angular.js code:
<ngx-gauge
[type]="gaugeType"
value={{item.currentJobStatus}}
[thresholds]="thresholdConfig"
label=""
[append]="gaugeAppendText"
[thick]="8"
size="100">
</ngx-gauge>
currentJobStatus
in the output is giving me 13.167
, but I only want 13.16
尝试使用类型转换... toFixed不适用于字符串。
console.log(parseFloat(13.167).toFixed(2));
Step 1.Take some variable var foo;
Step 2.Assign calculation part to variable foo=cncActiveState[0].totaltime * 100 / Number(stdcycletime[0].Standard_Cycle_Time;
Step 3.Then use toFixed()method in the push()method. currentJobStatus.push(foo.toFixed());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.