looking for this equivalent functions in c++

in pascal you just write round x or abs x and outputs what u want

im searching like half an hour the msdn found something for abs but its of type int abs( int n );

Printable View

- 02-02-2002asimosround and abs in c++
looking for this equivalent functions in c++

in pascal you just write round x or abs x and outputs what u want

im searching like half an hour the msdn found something for abs but its of type int abs( int n ); - 02-02-2002SyntaxBubbletry this...
I'm not sure bout rounding but for abs:

#include <math.h>

#include <iostream.h>

#include <stdlib.h>

int main() {

int number = -5;

cout << abs(number);

system("PAUSE");

return 0;

} - 02-02-2002Unregistered
There is ceil() and floor(); and setprecision(); and of course truncation, but I don't know of a standard rounding function. I've seen some 3rd party versions that don't look to tough to write, so give a shot yourself and see what you come up with

- 02-02-2002asimos
isnt that weird a whole prog. language like c++ doesnt have a

predifined function for round

anyways ill try something out

hehehe - 02-02-2002Stoned_Coder
to round to nearest int....

int Round( double in)

{

return (floor (in+0.5));

} - 02-02-2002asimos
int rounding( float y,float yaxis)

{

double a;

char &buffer;

int decimal,sign;

a = (y+10)/yaxis;

buffer = _fcvt( a, 0 , &decimal , &sign );

return buffer;

};

well after doing some research in the msdn i found this and modified and made this function

but i get an error

cannot convert from 'char *' to 'char'

This conversion requires a reinterpret_cast, a C-style cast or function-style cast

Error executing cl.exe. - 02-02-2002asimos
ok boys i managed thx to the last guy for the help

int round(float y, float yaxis)

{

double in;

in = (y+10)/yaxis;

return (floor (in+0.5));

};