如何在 Java 中转换此 Objective C 代码?
NSMutableString * thisPart = [[NSMutableString alloc] init];
UInt64 intVal = (UInt64)[thisPart longLongValue];
if (!intVal) { isBad = YES; break; }
我一直在网上搜索,但没有在网上找到任何有用的信息。
如果我有:
UInt32 _tmpPacket_packetId;
_tmpPacket_packetId = (UInt32)intVal; // UInt64 intVal = (UInt64)[thisPart longLongValue];
我可以这样做吗:
BigInteger tmpPacket_packetId = intVal;
实际上正确的问题是:为了获得与在 Objective C 中完成的相同的事情,这样做是否正确?
最佳答案
我假设您不关心 NSMutableString 位,它可能类似于 StringBuilder/StringBuffer 类。 UInt64 似乎是 64 位无符号整数?然后你可以使用 BigInteger(String) 提供的 String 构造函数
StringBuilder thisPart = new StringBuilder("12345678901234567890");
try {
BigInteger intVal = new BigInteger(thisPart.toString());
} catch (NumberFormatException e) {
System.out.println("Bad value");
isBad = true;
break; // or return or what have you
}
关于java - Java 中 Objective C 的 longLongvalue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7204306/