Win a copy of Spring Boot in Practice this week in the Spring forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Tim Cooke
• Ron McLeod
• Jeanne Boyarsky
• Paul Clapham
Sheriffs:
• Liutauras Vilda
• Henry Wong
• Devaka Cooray
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Tim Holloway
• Al Hobbs
• Carey Brown
Bartenders:
• Piet Souris
• Mikalai Zaikin
• Himai Minh

Ranch Hand
Posts: 74
• Number of slices to send:
Optional 'thank-you' note:
So I got my nitpick back for Grains, actually got it back twice today. I am having a difficult time with probably one of the easier assignments, but for some reason I can't figure it out. I have been told that double precision is not accurate enough for the assignment, so could somebody go over the differences between the three: long, float, double

long - 2^64
float - 2^32
double - 2^64
(all are signed)

is that correct and if so, what am I suppose to use instead of double, because when I use long I get a -2 (like an unplanned overflow). Plus I think I have found the method that I was suppose to use, but it only comes in double, not vanilla, cholocate, or long. Any help would be greatly appreciated.

Thanks again
Tony

Sheriff
Posts: 9109
12
• Number of slices to send:
Optional 'thank-you' note:

Originally posted by Tony VanHorn:
... so could somebody go over the differences between the three: long, float, double

long - 2^64
float - 2^32
double - 2^64
(all are signed)

is that correct and if so, what am I suppose to use instead of double, because when I use long I get a -2 (like an unplanned overflow). Plus I think I have found the method that I was suppose to use, but it only comes in double, not vanilla, cholocate, or long. Any help would be greatly appreciated.

You're correct in concluding that a long won't work for problem Java-6.

The clue is in the problem statement...you need to follow the link to the Sun web site and find a class that will provide you with the numeric range you need to solve the problem.

A double provides a floating point data type. A double will give you an answer something like 9.223372E18. It won't give you the exact answer, which is 9223372036854775808 grains on the 64th square. Hence the challenge of this problem: find a class that mimics a data type that covers a number this big.

Tony VanHorn
Ranch Hand
Posts: 74
• Number of slices to send:
Optional 'thank-you' note:
So, which is the java standard library. Is it just the java.lang? If it is, then I wouldn't be able to use java.Math. If it isn't, then I need to find some sort of reading that can help me better understand classes/packages.

Tony

Marilyn de Queiroz
Sheriff
Posts: 9109
12
• Number of slices to send:
Optional 'thank-you' note:
So, which is the java standard library. Is it just the java.lang?

Yes, java.lang is the standard java library.

If it is, then I wouldn't be able to use java.Math. If it isn't, then I need to find some sort of reading that can help me better understand classes/packages.

You're looking for a class that is not in java.lang.

Rancher
Posts: 43028
76
• Number of slices to send:
Optional 'thank-you' note:

Originally posted by Marilyn de Queiroz:
So, which is the java standard library. Is it just the java.lang?

Yes, java.lang is the standard java library.

Hmm, I've never heard the therm "standard Java library" used to indicate just the java.lang package. It generally means all of java.*, and often javax.* packages as well if they're part of J2SE.

Marilyn de Queiroz
Sheriff
Posts: 9109
12
• Number of slices to send:
Optional 'thank-you' note:
I deleted many of the posts in this thread because we don't want to give a student the answer, we want to help him find the correct package and class by providing information on how he can find that for himself.

You have a point, Ulf. Let me clarify my statement. The java.lang package is available for developers to use without adding import statements to the code. Classes in other packages in the j2sdk do not require a separate jar, but they do need to be imported.

We are looking for a class in this assignment is not in the java.lang package, and primitives (int, long, float or double) are not classes.

Tony, do you have the Just Java 2 book? If so, you can find a hint in the chapter on Names, Operators and Accuracy.
[ March 17, 2007: Message edited by: Marilyn de Queiroz ]

Tony VanHorn
Ranch Hand
Posts: 74
• Number of slices to send:
Optional 'thank-you' note:
I have the book, and thanks. I will look there.

To complete this assignment, you will need to find a class in the Java standard library that you have not used yet.

This is the quote from the assignment I was having difficulty with. So, the class I am looking for is in the java.*, which is really what is consider the standard library. Sorry if my questions seem dense, I just have to clarify for myself. Thanks

Tony

Sheriff
Posts: 4012
6
• Number of slices to send:
Optional 'thank-you' note:

Originally posted by Tony VanHorn:
So, the class I am looking for is in the java.* ...

Yep, that'll be yer huntin' grounds pardner.

Marilyn de Queiroz
Sheriff
Posts: 9109
12
• Number of slices to send:
Optional 'thank-you' note: