变体双子类型超过最大值 [英] variant double subtype exceed max value

查看:222
本文介绍了变体双子类型超过最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我查看变式数据类型文档时,它表示具有double类型的变体可以支持最大值为1.79769313486232E308(15位数字)的正值,而
发生错误当包含货币,十进制和双倍值的变量变量超出其各自的范围。
但是,当我运行以下代码时:

when I'm looking at the "Variant Data Type" documantation, it says that variant with subtype of double can support a positive value of maximum "1.79769313486232E308" (15 digits) and that "An error occurs when Variant variables containing Currency, Decimal, and Double values exceed their respective ranges." However, when I'm running the following code:

y = 999999999999999999999999999
y = CStr(CDBL(y))
MsgBox y

我不会收到错误,而是我得到具有以下输出的msgbox:1e + 27(27是y中的位数)。

I do not recive an error, instead I am getting a msgbox with the following output: "1e+27" (27 is the number of digits in y).

这是什么? y如何存储在内存中?

What is the explantion to this? how is "y" stored in the memory?

我没有在变体文档和CDbl函数文档中找到答案。

I havn't found an answer nither in variant documentation nor in CDbl function documentation.

谢谢。

推荐答案

在将数值分配给变体时,vbscript运行时将选择

On assignment of a numerical quantity to a variant, the vbscript runtime will pick the best possible variant type to match that quantity.

在您的情况下,文字对于整数类型来说太大,因此将其分配给 double 子类型。

In your case, the literal is too large for an integral type so it assigns it to the double "subtype".

将这个大小的双倍转换为字符串将产生一个科学符号的字符串。

Converting a double of this magnitude to a string will produce a string in scientific notation.

对于您的文档


1.79769313486232E308(15位数字)

"1.79769313486232E308" (15 digits)

有点误导。读取15 有效数字,这是关于浮点数 double 精度类型的精度级别。

is a little misleading. Read it as 15 significant figures which is about the precision level for a floating point double precision type.

这篇关于变体双子类型超过最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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