-1

I'm handling with some numbers and I want to add to the rounded number a specific faktor.

Like:

if round down -> add 150 if round up -> add 100

Is there any possibility to check if the computer is rounding up or down?

4

1 回答 1

3

你可以知道你是像这样向上还是向下取整

float roundedNbr = Math.round(originalNbr);

if(roundedNbr < originalNbr) {
    // We rounded down
} else if (roundedNbr > originalNbr) {
    // We rounded up
} else {
    // No rounding
}
于 2013-07-08T09:11:04.130 回答