Link to home
Start Free TrialLog in
Avatar of xtvca
xtvca

asked on

bcb4 ROUND(x,2)

I'm trying to cut my float values to 2 decimals precision somthing like 1.2345 to be 1.23
I found the ROUND function in borland c++ builder help but when i try to implement this function i'm getting error about function name (ROUND)
i also included math.h but it still dont work
I know that i can multiply my nuber with 100 and then roundit down to 0 decimal places and then devide it with 100 to get what i need but it is to messy

What's wrong with ROUND

Regards,Vedran
Avatar of jbodom
jbodom

All of the all upper case functions are not a part of the C++ language but routines in one of the ActiveX controls that comes with BCB.  

You could use the floor() and ceil() functions.


 #include <math.h>
 #include <stdio.h>

 int main(void)
 {
    double number = 123.54;
    double down, up;

    down = floor(number);
    up = ceil(number);

    printf("original number     %5.2lf\n", number);
    printf("number rounded down %5.2lf\n", down);
    printf("number rounded up   %5.2lf\n", up);

    return 0;
 }
ASKER CERTIFIED SOLUTION
Avatar of AlexVirochovsky
AlexVirochovsky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xtvca

ASKER

Thanks for details
Regards

Vedran