What are the values of a double/float on iOS, or the file that they're defined in? Or a macro, like INT_MAX?
Asked
Active
Viewed 3.5k times
3 Answers
155
I believe it's in <float.h>
: FLT_MAX
, DBL_MAX
, etc.
![](../../users/profiles/3737.webp)
Jesse Rusak
- 54,013
- 12
- 95
- 102
-
27because DOUBLE_MAX would be too difficult to remember... -_- – Herr Grumps Dec 10 '13 at 09:47
-
30@HerrGrumps In olden days, identifiers had to be unique in the first 8 characters, so `DOUBLE_MAX` would be the same as `DOUBLE_MIN`, which would be awkward. – Jesse Rusak Dec 10 '13 at 12:39
-
Actually it was 6 (case-insensitive) characters AFAIK, so the `X` was even not necessarily considered but `DBL_MA` vs `DBL_MI`. Somehow scary :) See also http://stackoverflow.com/questions/2352209/max-identifier-length – stefanct Sep 30 '14 at 13:05
10
On the iOS simulator, I logged LONG_MAX
, FLT_MAX
and DBL_MAX
. Here's what I got:
long max value: 9223372036854775807
float max value: 340282346638528859811704183484516925440.000000
double max value: 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000
Side note, if you use NSNumber
it uses the appropriate type to store your number.
![](../../users/profiles/591487.webp)
inorganik
- 21,174
- 17
- 78
- 101
4
If you need max value for CGFloat
you should use safely defined CGFLOAT_MAX
.
![](../../users/profiles/6248762.webp)
romanilchyshyn
- 351
- 2
- 14