Re: double vs float
- From: "santosh" <santosh.k83@xxxxxxxxx>
- Date: 3 Mar 2007 23:02:32 -0800
Jack Klein wrote:
On 3 Mar 2007 19:48:49 -0800, "santosh" <santosh.k83@xxxxxxxxx> wrote
in comp.lang.c:
subramanian100in@xxxxxxxxx, India wrote:
In the post with heading "Learning C - Scanf or Getch, or Getchar not
working correctly after first loop" that appears in today's list in
comp.lang.c,
it has been mentioned in the answer to this post, that double should
be preferred to float when space is not a constraint.
Can someone explain why double should be preferred to float ?
Usually it's because double corresponds more closely with the system's
native floating point type than float. Also, it gives more range and
precision than float, which is an important point when using floating-
point types.
After reading your points I realise I may have been incorrect in my
assumptions.
What system is it that has "a" native floating point type, only one
that is, that corresponds more closely to double than float?
Well the IA32 architecture has an 80 bit hardware floating point type,
to which the C double would correspond more closely than a float.
Your answer makes no sense at all, for several reasons:
1. If a platform only has a single floating point type supported in
hardware, and it meets the requirements for C's double, there is
nothing at all preventing the C implementation from using it for float
as well.
Except for the fact that one of float's purpose is to reduce memory
requirements.
2. I can't think of any hardware architecture off-hand that has
hardware floating point for something suitable for a double, such as
64 bits or more, that does not also have hardware support for a
narrower floating point type.
On the other hand, I know of quite a few platforms where the opposite
is true, including 32-bit controllers and DSPs, namely that they have
hardware 32-bit floating point, which meets the C requirements for
float, but not a wider hardware floating point type.
I stand corrected.
.
- References:
- double vs float
- From: subramanian100in@xxxxxxxxx, India
- Re: double vs float
- From: santosh
- Re: double vs float
- From: Jack Klein
- double vs float
- Prev by Date: Re: C Strings
- Next by Date: Re: C Strings
- Previous by thread: Re: double vs float
- Next by thread: Re: double vs float
- Index(es):
Relevant Pages
|
|