• Forum
  • Lounge
  • Why is double the default floating point

 
Why is double the default floating point type?

Like the question askes, does anyone have any idea why double was chosen as the default floating point decimal? By default, I mean that when you declare 1.0, it's a double, but to simulate a smaller memory variable, you need to type the f, 1.0f. int makes sense to be the default, but I figure float would as well.
closed account (o3hC5Di1)
Hi there,

I wouldn't be able to tell you myself, but:

Here's someone asking pretty much the same question on stackoverflow:
http://stackoverflow.com/questions/4353780/why-floating-point-value-such-as-3-14-are-considered-as-double-by-default-in-msv

This one seems related as well:
http://stackoverflow.com/questions/399114/why-are-c-c-floating-point-types-so-oddly-named

Other interesting threads that came up:
http://www.daniweb.com/software-development/cpp/threads/176435/difference-between-float-and-double
http://stackoverflow.com/questions/158889/are-doubles-faster-than-floats-in-c

All the best,
NwN
Last edited on
Because most ALUs take the same amount of time to operate on doubles as on floats. Even further, some of them process floats slower than doubles, because additional conversions from float to double and back are required. On the other hand, floats might be faster if compiler vectorizes code to SSE - because more floats fit into registers. However, when the C/C++ specs were created, SSE was not yet there.
Last edited on
Topic archived. No new replies allowed.