如何在dart / flutter中声明64位unsigned int? [英] How do I declare 64bit unsigned int in dart/flutter?

查看:1017
本文介绍了如何在dart / flutter中声明64位unsigned int?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个应用程序,我需要一个64位无符号整数。在查看dart文档时,我没有看到如何正确声明。

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

有人可以告诉我这是怎么做的吗?我将在按位操作中使用此 64位无符号整数。

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

推荐答案

Dart没有本地无符号64位整数。

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

对于许多操作,您只需使用 signed 64位整数即可,该整数是 int 是,并将其解释为无符号。都是一样的不过,这不适用于部门划分。 (如果是用于网络,则 int 是一个JavaScript数字,您需要做一些完全不同的事情。)

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).

最简单的常规方法是在执行任何操作后使用 BigInt 并使用 toUnsigned(64)

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

这篇关于如何在dart / flutter中声明64位unsigned int?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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