What is the max. value of a double/float on iOS?

IosCObjective CDouble

Ios Problem Overview


What are the values of a double/float on iOS, or the file that they're defined in? Or a macro, like INT_MAX?

Ios Solutions


Solution 1 - Ios

I believe it's in <float.h>: FLT_MAX, DBL_MAX, etc.

Solution 2 - Ios

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.

Solution 3 - Ios

If you need max value for CGFloat you should use safely defined CGFLOAT_MAX.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontadejsvView Question on Stackoverflow
Solution 1 - IosJesse RusakView Answer on Stackoverflow
Solution 2 - IosinorganikView Answer on Stackoverflow
Solution 3 - IosromanilchyshynView Answer on Stackoverflow