Python int太大,无法在Python COM中转换为C long

时间:2022-06-24 18:19:54

I have a python method that calculates value and returns it. The value is

我有一个python方法,计算值并返回它。价值是

CalcData = 3941269503L. 

It is only 32 bit. Yet this is typecasted to long implicitly (suffixed by L) and when I access this method in COM in other application , I get the Python int too large to convert to C long error. I even tried typecasting it into int,but no luck

它只有32位。然而,这是长期隐式(后缀为L)的类型,当我在其他应用程序中的COM中访问此方法时,我得到的Python int太大而无法转换为C long错误。我甚至尝试将其转换为int,但没有运气

1 个解决方案

#1


2  

The "long" C type is signed so the largest positive value it can store is 2,147,483,647. The error is indeed correct, it doesn't fit.

“long”C类型已签名,因此它可以存储的最大正值为2,147,483,647。错误确实是正确的,它不适合。

Try "unsigned long" and "UL" postfix on the constant.

在常量上尝试“unsigned long”和“UL”后缀。

#1


2  

The "long" C type is signed so the largest positive value it can store is 2,147,483,647. The error is indeed correct, it doesn't fit.

“long”C类型已签名,因此它可以存储的最大正值为2,147,483,647。错误确实是正确的,它不适合。

Try "unsigned long" and "UL" postfix on the constant.

在常量上尝试“unsigned long”和“UL”后缀。