티스토리 뷰

반응형

 

 

The Dart int type is a 64-bit two's complement number—except when compiled for the web, there it's a 64-bit floating point number with no fractional part (a JavaScript number which has an integer value).

How those values are represented internally depends on optimizations, they can be represented as something smaller if the runtime system knows for sure that the value will fit. That's an optimization, you won't be able to tell the difference.

A "byte" value is an integer in the range 0..255. You can obviously store a byte value in an int.

The most efficient way to store multiple bytes is a Uint8List, which implements List<int>. It stores each element as a single octet. When you read a value out of a Unit8List, its byte value is represented by an int. When you store an int in the Uint8List, only the low 8 bites are stored. So it does expanding reads and truncating writes to move values between an octet and a 64-bit value.

 

 

https://stackoverflow.com/questions/64018460/how-does-an-int-represent-a-byte-8-bits-when-an-int-is-normally-32-or-64-bit

 

How does an "int" represent a byte (8 bits) when an int is normally 32 or 64 bits?

I'm curious how in the Dart programming language a byte is represented by the int type. I am is confusing because in Java, which Dart closely resembles, an int is 32 bits. I ask because the leading

stackoverflow.com

 

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함