什么是最大值。iOS 上 double/float 的值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4706349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the max. value of a double/float on iOS?
提问by tadejsv
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 上的 double/float 或定义它们的文件的值是什么?或者像 INT_MAX 这样的宏?
回答by Jesse Rusak
I believe it's in <float.h>
: FLT_MAX
, DBL_MAX
, etc.
我相信这是<float.h>
:FLT_MAX
,DBL_MAX
,等。
回答by inorganik
On the iOS simulator, I logged LONG_MAX
, FLT_MAX
and DBL_MAX
. Here's what I got:
在 iOS 模拟器上,我登录了LONG_MAX
,FLT_MAX
和DBL_MAX
. 这是我得到的:
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.
旁注,如果您使用NSNumber
它,请使用适当的类型来存储您的号码。
回答by romanilchyshyn
If you need max value for CGFloat
you should use safely defined CGFLOAT_MAX
.
如果您需要最大值,CGFloat
则应使用安全定义的CGFLOAT_MAX
.