Home > Back-end >  Double n;
Double n;

Time:10-03

N=int (n * 100 + 0.5)/100.0;
Want to help the two statements expressing what meaning, thank you!

CodePudding user response:

From the result is rounded part n
What's the context?

CodePudding user response:

Wrong, n, n * 100 (+ 0.5) first to int, divided by a floating, or floating

CodePudding user response:

refer to the second floor qybao response:
no, n, n * 100 (+ 0.5) to int, first in divided by the number of floating point, or floating point

(n * 100 + 0.5) is for the sake of what

CodePudding user response:

Two digits after the decimal point and rounded

CodePudding user response:

Is rounded, achieve the goal that keep two decimal places.

For example,
N=0.00555;
Int (n * 100 + 0.5)=1, divided by 100=0.01000

N=0.00455;
Int (n * 100 + 0.5)=0, divided by 100=0.00000

CodePudding user response:

reference 5 floor qybao reply:
is rounded, achieve the goal that keep two decimal places.

For example,
N=0.00555;
Int (n * 100 + 0.5)=1, divided by 100=0.01000

N=0.00455;
Int (n * 100 + 0.5)=0, divided by 100=0.00000

Understand, thank you??
  • Related