Trying to use rint() 
Author Message
 Trying to use rint()

I need to round a double into an integer value and have been trying to use
the rint() function.  From what I've researched, I thought rint() was a
standard in math.h... but my compiler (vc6) is not recognizing it even with
math.h #included.

Any suggestions?

Thanks in advance.

Kristin



Tue, 25 Feb 2003 22:51:54 GMT  
 Trying to use rint()
Greets,

    Are you sure this isn't a java class library function?  You may consider
looking at floor() and ceil() and then converting to an integer value.

Regards,

Joe


Quote:
> I need to round a double into an integer value and have been trying to use
> the rint() function.  From what I've researched, I thought rint() was a
> standard in math.h... but my compiler (vc6) is not recognizing it even
with
> math.h #included.

> Any suggestions?

> Thanks in advance.

> Kristin



Tue, 25 Feb 2003 23:04:25 GMT  
 Trying to use rint()
No... my colleague uses it in his "C" code for linux platform.


Quote:
> Greets,

>     Are you sure this isn't a java class library function?  You may
consider
> looking at floor() and ceil() and then converting to an integer value.

> Regards,

> Joe



> > I need to round a double into an integer value and have been trying to
use
> > the rint() function.  From what I've researched, I thought rint() was a
> > standard in math.h... but my compiler (vc6) is not recognizing it even
> with
> > math.h #included.

> > Any suggestions?

> > Thanks in advance.

> > Kristin



Wed, 26 Feb 2003 03:16:03 GMT  
 Trying to use rint()

Greets,

    Ah, unfortunately I do not see it in the VC++ library and I'm making a
guess here, but I would assume it is not part of the standard 'C' library.
It is possible that this is an extension to the library.  The nice thing, I
would imagine, is that you can probably port the code for this function and
use it under Win32 fairly easily.

Regards,

Joe


Quote:
> No... my colleague uses it in his "C" code for linux platform.



> > Greets,

> >     Are you sure this isn't a java class library function?  You may
> consider
> > looking at floor() and ceil() and then converting to an integer value.

> > Regards,

> > Joe



> > > I need to round a double into an integer value and have been trying to
> use
> > > the rint() function.  From what I've researched, I thought rint() was
a
> > > standard in math.h... but my compiler (vc6) is not recognizing it even
> > with
> > > math.h #included.

> > > Any suggestions?

> > > Thanks in advance.

> > > Kristin



Wed, 26 Feb 2003 03:23:30 GMT  
 Trying to use rint()

Quote:

>I need to round a double into an integer value and have been trying to use
>the rint() function.  From what I've researched, I thought rint() was a
>standard in math.h... but my compiler (vc6) is not recognizing it even with
>math.h #included.

>Any suggestions?

I believe rint is a C9X (the latest C Standard) function. You may be
able to use something like the following in its place:

#include <math.h>

double Round(double x)
{
   return (x >= 0) ? floor(x+0.5) : ceil(x-0.5);

Quote:
}

This function rounds away from zero.

--
Doug Harrison [VC++ MVP]
Eluent Software, LLC
http://www.eluent.com
Tools for Visual C++ and Windows



Wed, 26 Feb 2003 05:32:48 GMT  
 Trying to use rint()

Kristin:

int rint(double x)
{
  return (int)(x > 0 ? x+0.5 : x-0.5);

Quote:
}

(untested)

HTH,

David Wilkinson

================

Quote:

> I need to round a double into an integer value and have been trying to use
> the rint() function.  From what I've researched, I thought rint() was a
> standard in math.h... but my compiler (vc6) is not recognizing it even with
> math.h #included.

> Any suggestions?

> Thanks in advance.

> Kristin



Fri, 28 Feb 2003 18:14:29 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. rint()

2. scanf, rint and doubles...

3. rint math function

4. Problem with rint() on HP?

5. rint() function, and Visual C++ library

6. differences between [rint and printPreview

7. using try function in c

8. Some problems trying to create users in AD using C#

9. C# , i am trying to create a file on the server using C#

10. Exception trying to open file using mfc dao

11. Need help with trying to get the host name from the ip number using gethostbyaddr

12. Using Try and Catch

 

 
Powered by phpBB® Forum Software