Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart equivalent of long? [duplicate]

Tags:

flutter

dart

What is the equivalent of java's long datatype in dart ? should int or long be used?

like image 345
Henok Avatar asked Jul 22 '19 03:07

Henok


People also ask

Does Dart have long?

The signed long has a minimum value of -2^63 and a maximum value of 2^63-1. In Java SE 8 and later, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 2^64-1. Use this data type when you need a range of values wider than those provided by int.


1 Answers

In Java:

long: The long data type is a 64-bit two's complement integer. The signed long has a minimum value of -2^63 and a maximum value of 2^63-1. In Java SE 8 and later, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 2^64-1. Use this data type when you need a range of values wider than those provided by int. The Long class also contains methods like compareUnsigned, divideUnsigned etc to support arithmetic operations for unsigned long.

In Dart:

int Integer values no larger than 64 bits, depending on the platform. On the Dart VM, values can be from -2^63 to 2^63 - 1. Dart that’s compiled to JavaScript uses JavaScript numbers, allowing values from -2^53 to 2^53 - 1.

So, you can exactly use int in Dart for the equivalent of long in Java. But beware of the caveat when compiled to JavaScript.

like image 73
ישו אוהב אותך Avatar answered Sep 22 '22 05:09

ישו אוהב אותך