yangxu998 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Consider adding BYTES constant to all primitives classes #668

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There's a BYTES on Chars, but nothing else (I think).
It would be useful to have a BYTES on all of the primitives classes:
 (Booleans, Bytes, Chars, Doubles, Floats, Ints, Longs, Shorts, SignedBytes, UnsignedBytes).

The JDK wrappers provide a SIZE in bits, which of course has to be divided down.

The Primitives class itself could use 
 static int bits(Class clazz)
 static int bytes(Class clazz)
which would throw on a class that isn't a JDK primitive wrapper.

FWIW, see 
http://stackoverflow.com/questions/6766343/best-practice-for-getting-datatype-si
zesizeof-in-java/6772163#6772163 for what motivated me to write.

Original issue reported on code.google.com by esta...@comcast.net on 21 Jul 2011 at 2:11

GoogleCodeExporter commented 9 years ago
Appears to be missing on floats, and doubles (and possibly bytes).

Created issue 672 for the second request.

Original comment by fry@google.com on 28 Jul 2011 at 5:30

GoogleCodeExporter commented 9 years ago

Original comment by wasserman.louis on 26 Aug 2011 at 3:34

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09