Re: double is integer?
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Mon, 05 Feb 2007 12:02:18 -0600
On Sat, 03 Feb 2007 20:12:57 -0500, Joseph M. Newcomer
<newcomer@xxxxxxxxxxxx> wrote:
There is no reliable way to actually compare doubles to integers and know that the double
is an integer value.
That's a little pessimistic. Doubles are required to support at least 10
decimal digits of precision, and every implementation I've seen is exact
when dealing with integers and simple arithmetic whose range is the
integers. It's only when you get into overflow (WRT the range of the
integer type in question) or fractions that it becomes imprecise. It's not
unheard of to use double essentially as a large integer in 32 bit
implementations that have no larger integer type; since double typically
has 15 decimal digits of precision, this may allow you to use the full
range of int/long while relieving you of overflow worries. ISTR seeing an
implementation of mktime that did this.
--
Doug Harrison
Visual C++ MVP
.
- References:
- double is integer?
- From: Guido Franzke
- Re: double is integer?
- From: Joseph M . Newcomer
- double is integer?
- Prev by Date: Re: Returning complex object or using reference [out] parameter
- Next by Date: Re: BringWindowToFront/SetForegroundWindow problem
- Previous by thread: Re: double is integer?
- Next by thread: Recommend a debugger
- Index(es):
Relevant Pages
|