Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 764
tadejsv Avatar asked Jan 16 '11 15:01

tadejsv


People also ask

What is the max value of a double?

The value of this constant is positive 1.7976931348623157E+308.

What is the max value of a float in C++?

short: min: -32768 max: 32767 int: min: -2147483648 max: 2147483647 long: min: -2147483648 max: 2147483647 float: min: 1.17549e-038 max: 3.40282e+038 double: min: 2.22507e-308 max: 1.79769e+308 long double: min: 2.22507e-308 max: 1.79769e+308 unsigned short: min: 0 max: 65535 unsigned int: min: 0 max: 4294967295 ...

What is float MaxValue?

Represents the largest possible value of Single. This field is constant. public: float MaxValue = 3.40282347E+38; C# Copy.

What does double mean in Swift?

Swift provides two signed floating-point number types: Double represents a 64-bit floating-point number. Float represents a 32-bit floating-point number.


2 Answers

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

like image 79
Jesse Rusak Avatar answered Sep 25 '22 18:09

Jesse Rusak


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.

like image 23
inorganik Avatar answered Sep 23 '22 18:09

inorganik