How do I declare 64bit unsigned int in dart/flutter?

守給你的承諾、 提交于 2019-12-04 04:04:41

问题


For an app, I need a 64bit unsigned int. Looking at dart documentation I did not see how to exactly go about declaring one.

Can anyone tell me how this is done? I will use this "64bit unsigned int" in bitwise operation.


回答1:


Dart does not have a native unsigned 64-bit integer.

For many operations, you can just use the signed 64-bit integer that an int is, and interpret it as unsigned. It's the same bits. That won't work with division, though. (And if it's for the web, then an int is a JavaScript number, and you need to do something completely different).

The simplest general approach is to use a BigInt and use toUnsigned(64) after you do any operations on it.



来源:https://stackoverflow.com/questions/53589309/how-do-i-declare-64bit-unsigned-int-in-dart-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!