可能的QML最高数字(浮点数/整数) [英] QML highest number (float/integer) possible

查看:244
本文介绍了可能的QML最高数字(浮点数/整数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JavaScript中,最大可能的整数是通过

In JavaScript the highest integer possible is defined via

Number.MAX_SAFE_INTEGER.

以及在C ++中也可以通过std获得:

and also in C++ can be obtained with the std:

std::numeric_limits<int>::max()

QML 中对于整数或双精度有这样的常量吗?

Is there such a constant in QML for ints or doubles?

推荐答案

正如最初怀疑的那样,文档中列出的 2000000000 数字不正确.而且,IMO这是一个重要的值,实际上不应该受到如此粗心的近似.在周围"仅在不确定或不重要的实际值时才应使用.

As originally suspected, the 2000000000 number listed in the documentation is incorrect. Also, IMO this is an important value that shouldn't really be subject to such careless approximations. "Around" should only be used when the actual value is unknown for certain or not crucial.

一个简单的测试可以验证QML中的 int 属性的最大可能值是 2147483647 ,或者是预期的 2 ^ 31-1

A simple test verifies that the largest possible value for an int property in QML is 2147483647, or as expected 2^31 - 1.

请注意,这与JS东西 Number.MAX_SAFE_INTEGER 不同,并且该值是 2 ^ 53-1 -大大高于 int会给您. Number 是64位实数数据类型,它通过使用数字的53个小数位来支持整数,因此11个指数位未使用.

Note that this is different from Number.MAX_SAFE_INTEGER which is a JS thing, and that value is 2^53 - 1 - substantially higher than what int will give you. Number is a 64 bit real data type, and it supports integers by using the 53 fraction bits of the number, the 11 exponent bits are left unused.

在5.15或更早的版本中,可以使用无符号32位int的完整范围,使qml的 int 类型的有效范围加倍,但是您必须使用var 作为属性类型,甚至可能使用uint64且其值在 ^ 53 范围内.

In 5.15 and possibly earlier, it is possible to use the full range of an unsigned 32 bit int, doubling the effective range over qml's int type, but you have to use var as the property type, it may even be possible to use uint64 with values within the ^53 range.

这篇关于可能的QML最高数字(浮点数/整数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆