Re: Comparission cause problem
From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: 02/17/05
- Next message: Francis Glassborow: "Re: This I simply can't swallow"
- Previous message: Martijn Mulder: "Re: int a = ++b + ++b;"
- In reply to: ranjeet: "Re: Comparission cause problem"
- Next in thread: Karl Heinz Buchegger: "Re: Comparission cause problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 17 Feb 2005 08:30:38 +0000
In article <77c88a3b.0502162127.1009bb68@posting.google.com>, ranjeet
<ranjeet.gupta@gmail.com> writes
> I think I may be missing some points thats why, I have some doubts on the
> above. Please guide me to clear the things in brief. what I am missing.
What you are missing is that most modern processors have floating point
arithmetic units. These are designed to work with a floating point type
that is wider than a float (typically they use an 80-bit type). The
second issue is that in most circumstances the standard conversions are
applied in C and C++ (less so in C++) which promote a float to a double
so if you insist on using a float you may be incurring promotion and
demotion costs as well.
In simple terms the natural floating point type for C and C++ is double
and the natural floating point type for many general purpose CPUs is
either double or something wider than that.
The assumption that float will be faster than double is often false, and
even when it isn't double is generally fast enough.
-- Francis Glassborow ACCU Author of 'You Can Do It!' see http://www.spellen.org/youcandoit For project ideas and contributions: http://www.spellen.org/youcandoit/projects
- Next message: Francis Glassborow: "Re: This I simply can't swallow"
- Previous message: Martijn Mulder: "Re: int a = ++b + ++b;"
- In reply to: ranjeet: "Re: Comparission cause problem"
- Next in thread: Karl Heinz Buchegger: "Re: Comparission cause problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|