十六进制转换为Int - Bug或我对VB.Net的误解 [英] Hex conversion to Int - Bug or My misunderstanding of VB.Net

查看:77
本文介绍了十六进制转换为Int - Bug或我对VB.Net的误解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到以下结果:


Cint(& HC5798A2F)应该返回-981890513和


Clng(" & HFFFFFFFFC5798A2F")应该返回-981890513。


但是当使用字符串时


Cint(& ;;& HC5798A2F" )返回一个溢出异常。


对于相同的十六进制格式数字输入,Cint不应该返回相同的值吗?

-

丹尼斯在休斯顿

解决方案

你有太多这些 - >"(...试试这个Cint (& HC5798A2F")

-Fabricio


" Dennis"写道:

我得到以下结果:

Cint(& HC5798A2F)应该返回-981890513并且

Clng(& HFFFFFFFFC5798A2F")返回-981890513 as它应该。

然而当使用一个字符串时

Cint("(& HC579) 8A2F)返回一个溢出异常。

对于相同的十六进制格式编号输入,Cint不应该返回相同的值吗?
-
Dennis in Houston


是的,这是一个错字,但是当我省去额外的

时我得到溢出异常(

" Fabricio"写道:

你有太多这些 - > (...试试这个Cint(& HC5798A2F)

-Fabricio

Dennis写道:

我得到以下结果:

Cint(& HC5798A2F)应该返回-981890513并且

Clng(& HFFFFFFFFC5798A2F")返回-981890513应该如此。

然而当使用字符串时

Cint("(& HC5798A2F")会返回溢出异常。

对于相同的十六进制格式编号输入,Cint不能返回相同的值吗?
-
Dennis in Houston


我想...只是检查你是否仍然活跃在这个帖子上:-)


好​​的......这是交易。它没有'因为您正在使用的十六进制数字,

C5798A2F,对于一个32位整数来说太大了。允许的最大值是

2,147,483,647。尝试一个较小的数字(字符串数字),看看是否rks。


-Fabricio
fg ** ***********@yahoo.com


" Dennis"写道:

是的,这是一个错字,但当我遗漏
额外时我得到溢出异常(

Fabricio写道:

你有太多这些 - >"(" ... ...试试这个Cint(&& HC5798A2F")

> -Fabricio

Dennis写道:

我得到以下结果:

Cint(& HC5798A2F)返回-981890513应该和

Clng(& HFFFFFFFFC5798A2F")按原样返回-981890513。

然而当使用字符串时
Cint("(& HC5798A2F")返回溢出异常。

对于同一个十六进制格式编号输入,Cint不应该返回相同的值吗?
-



I get the following results:

Cint(&HC5798A2F) returns -981890513 as it should and

Clng("&HFFFFFFFFC5798A2F") returns -981890513 as it should.

However when using a string

Cint("(&HC5798A2F") returns an overflow exception.

Shouldn''t the Cint return the same value for the same hex format number input?
--
Dennis in Houston

解决方案

You have one too many of these --> "("... try this Cint("&HC5798A2F")

-Fabricio

"Dennis" wrote:

I get the following results:

Cint(&HC5798A2F) returns -981890513 as it should and

Clng("&HFFFFFFFFC5798A2F") returns -981890513 as it should.

However when using a string

Cint("(&HC5798A2F") returns an overflow exception.

Shouldn''t the Cint return the same value for the same hex format number input?
--
Dennis in Houston



Yes, it was a typo but I get the overflow exception when I leave out the
extra (

"Fabricio" wrote:

You have one too many of these --> "("... try this Cint("&HC5798A2F")

-Fabricio

"Dennis" wrote:

I get the following results:

Cint(&HC5798A2F) returns -981890513 as it should and

Clng("&HFFFFFFFFC5798A2F") returns -981890513 as it should.

However when using a string

Cint("(&HC5798A2F") returns an overflow exception.

Shouldn''t the Cint return the same value for the same hex format number input?
--
Dennis in Houston



I figured... just checking to see if you were still active on this thread :-)

Ok... here''s the deal. It doesn''t work because the hex number you''re using,
C5798A2F, is too big for a 32-bit integer. The max value allowed is
2,147,483,647. Try a smaller number (string number) and see if that works.

-Fabricio
fg*************@yahoo.com

"Dennis" wrote:

Yes, it was a typo but I get the overflow exception when I leave out the
extra (

"Fabricio" wrote:

You have one too many of these --> "("... try this Cint("&HC5798A2F")

-Fabricio

"Dennis" wrote:

I get the following results:

Cint(&HC5798A2F) returns -981890513 as it should and

Clng("&HFFFFFFFFC5798A2F") returns -981890513 as it should.

However when using a string

Cint("(&HC5798A2F") returns an overflow exception.

Shouldn''t the Cint return the same value for the same hex format number input?
--
Dennis in Houston



这篇关于十六进制转换为Int - Bug或我对VB.Net的误解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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