Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (578)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  primitive sizes in bytes  (Read 1025 times)
0 Members and 1 Guest are viewing this topic.
Offline MickeyB

Senior Duke




my game will work, my game will work!


« Posted 2004-12-01 11:10:38 »

ok, I found an article on bytebuffers and nio on the net and it stated the following:

a short is 2 bytes in size
an int is 4 bytes in size
a long is 8 bytes in size


If these are true what size is a float? and are these accurate for the java lang?

thanks

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Offline kevglass

JGO Kernel


Medals: 191
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2004-12-01 11:27:10 »

Accurate. I believe that..

Float is 4.
Double is 8.

Could be wrong of course.

Kev

Offline MickeyB

Senior Duke




my game will work, my game will work!


« Reply #2 - Posted 2004-12-01 11:38:43 »

thanks!  I will give it a whirl!

MickeyB

Current Project: http://www22.brinkster.com/mbowles/
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Grazer

Junior Duke




My other avatar is much more flattering.


« Reply #3 - Posted 2004-12-05 23:37:48 »

Yep, those values are right.

You can read the below pages for a whole list w/ min and max values as well.

One thing to keep in mind is that all Java primitives (except boolean & character) are signed.
This can be annoying/a source of errors when reading or writing data from languages that allow unsigned values.

As an example, many file formats will use one byte to store values between 0 and 255. If you tried to read this into a Java byte, anything above 127 would be read in as a negative number, because Java bytes only go from -128 -> 127; you don't have the option of making it unsigned.
Hence, you have to read such values into the next type up, i.e. 1-byte unsigned values must be read into a short, 2-byte values into an int, etc.

Links:

http://www.chinalinuxpub.com/doc/oreillybookself/java/javanut/ch02_06.htm

OR

http://www.scism.sbu.ac.uk/jfl/Appa/appa1.html
http://www.scism.sbu.ac.uk/jfl/Appa/appa2.html

Current Project: Easy Decal
Other Stuff: grlea online
Offline Jeff

JGO Coder




Got any cats?


« Reply #4 - Posted 2004-12-06 04:28:10 »

Something to remember that might be obvious....

These are the sizes of their representations in a ByteBuffer.

What size a primative variable is in memory is totally VM dependnat.

(For instance I believe its still the case that the Sun VM internally stores indvidual byte variables in a full int.)

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Grazer

Junior Duke




My other avatar is much more flattering.


« Reply #5 - Posted 2004-12-06 04:49:43 »

Quote
What size a primative variable is in memory is totally VM dependnat.

(For instance I believe its still the case that the Sun VM internally stores indvidual byte variables in a full int.)

I've heard this before to and it stands to reason.
It seems likely that VMs written for a 32-bit system would use 32-bit words for everything that's either 32 bits (int) or smaller.

You'd probably find on phones (which I assume have 8- or 16-bit architectures?) this isn't the case.

Current Project: Easy Decal
Other Stuff: grlea online
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

DarkCart (16 views)
2014-10-31 21:44:48

DarkCart (21 views)
2014-10-31 21:43:57

TehJavaDev (40 views)
2014-10-27 03:28:38

TehJavaDev (31 views)
2014-10-27 03:27:51

DarkCart (44 views)
2014-10-26 19:37:11

Luminem (27 views)
2014-10-26 10:17:50

Luminem (30 views)
2014-10-26 10:14:04

theagentd (36 views)
2014-10-25 15:46:29

Longarmx (64 views)
2014-10-17 03:59:02

Norakomi (62 views)
2014-10-16 15:22:06
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!