Quick Java help, for my programming lab.

Talk about anything and everything not related to this site or the Dreamcast, such as news stories, political discussion, or anything else. If there's not a forum for it, it belongs in here. Also, be warned that personal insults, threats, and spamming will not be tolerated.
Post Reply
Thomas
Thomas
Posts: 2999
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Wed Feb 12, 2003 3:12 pm
Location: Ohio
Has thanked: 0
Been thanked: 0

Quick Java help, for my programming lab.

Post by Thomas »

For my programming lab I have to change the following..

Code: Select all

int test = 100: //Set the Test value here
In that line of code I have ot change the literal value 100 to the largest number that can be stored in a variable of type int. Now i have no idea what this is, anyone who can help by pointing me the dircection of a site with it, or can tell me, it would be a lot of help.


Edit: Is it 32,767?

Edit 2: I used INT_MAX, and got an error, but the lab asked if I got an error messgae, and it gave me high valuves for test +1, so I asume that is right?
User avatar
Disheveled DrFreeze
DCEmu Mega Fan
DCEmu Mega Fan
Posts: 2896
Joined: Tue Feb 24, 2004 10:23 am
Has thanked: 0
Been thanked: 0

Post by Disheveled DrFreeze »

if you have a book then you should be able to look up how many Bytes the datatype INT takes up

also, be sure to check if its a signed or unsigned int
DrFreeze, thinking outside the box since 1985
DrFreeze, licensed road terror since 2006
DrFreeze, Sun Certified Java Programmer since 2007
Thomas
Thomas
Posts: 2999
Joined: Wed Feb 12, 2003 3:12 pm
Location: Ohio
Has thanked: 0
Been thanked: 0

Post by Thomas »

Disheveled DrFreeze wrote:if you have a book then you should be able to look up how many Bytes the datatype INT takes up

also, be sure to check if its a signed or unsigned int
We've only done thei ntroduction chapter, and it had nothing about programs in there. All thei ntroduction program did was talk about the different componts of machines.
User avatar
Disheveled DrFreeze
DCEmu Mega Fan
DCEmu Mega Fan
Posts: 2896
Joined: Tue Feb 24, 2004 10:23 am
Has thanked: 0
Been thanked: 0

Post by Disheveled DrFreeze »

hmm i see

you might want to check the variables or data types chapter, and read the part about the int then
DrFreeze, thinking outside the box since 1985
DrFreeze, licensed road terror since 2006
DrFreeze, Sun Certified Java Programmer since 2007
Pyrosurfer
DCEmu Nutter
DCEmu Nutter
Posts: 964
Joined: Sun Aug 11, 2002 5:07 pm
Has thanked: 0
Been thanked: 0

Post by Pyrosurfer »

http://www.cafeaulait.org/course/week2/02.html

int
4 bytes, signed (two's complement). -2,147,483,648 to 2,147,483,647. Like all numeric types ints may be cast into other numeric types (byte, short, long, float, double). When lossy casts are done (e.g. int to byte) the conversion is done modulo the length of the smaller type.
User avatar
butters
Classic Games Lover
Classic Games Lover
Posts: 5088
Joined: Fri Feb 08, 2002 6:50 pm
Location: Lubbock, Texas, United States, Sol 3, Milky Way Galaxy
Has thanked: 0
Been thanked: 0

Post by butters »

They are trying to get you to look at sun.com's online references probably. Java is extremely well documented and it's worth looking at just to see what you can pull off.
Sanchez
DCEmu Ex-Admin
DCEmu Ex-Admin
Posts: 1098
Joined: Wed Oct 17, 2001 7:44 pm
Has thanked: 0
Been thanked: 0

Post by Sanchez »

You could also try an experiment and simply increment the value of an int until it overflows...
"This is worse than when the Raccoon got in the copier!"
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

Try Integer.MAX_VALUE (which should be 7FFFFFFF)
Thomas
Thomas
Posts: 2999
Joined: Wed Feb 12, 2003 3:12 pm
Location: Ohio
Has thanked: 0
Been thanked: 0

Post by Thomas »

I turned in the lab hopeing for the best. I just set the value as int_max and got no compiling errors. It may not be right, but it was only one question. I have another lab toom, which will probably be really annoying, and also my first program is due Thursday by 11:59pm.
Post Reply