> > Or am I missing something else here?
>
> You're missing every time someone has told you to look at the classes in
> the java.text package.
You assume that. I did have a look at those classes, yet found nothing of
importance that would help me, therefor I posted another possible solution.
> In particular, look at java.text.DecimalFormat. It has a constructor
> that takes a string that lets you set its output format, and a method
> format(double d) which produces a String from d, in the given format.
"Which produces a String" indeed, in which I am not interested. I want to
use the resulting double value, for which I can see no possible way to get
to via the DecimalFormat class, part from possibly a very wordy construct
involving the parse method.
Therefor I ask what is wrong with
for (int x=80;x<100;++x) {
System.out.println("Threshold " + (x*.01) );
}
which gives me the correct result - or at least appears to do so.
Thanks,
Princess Morgiah
Carl Howells - 22 Apr 2004 21:17 GMT
> "Which produces a String" indeed, in which I am not interested. I want to
> use the resulting double value, for which I can see no possible way to get
> to via the DecimalFormat class, part from possibly a very wordy construct
> involving the parse method.
Ahh.. That's important. I didn't realize, and I suspect most people
reading the thread also didn't realize, that you wanted to continue
treating the values as doubles. In your example, you only were
displaying them, which led me to believe the wrong thing.
In that case, it seems what you're looking for is a general set of rules
for working with floating point types to minimize cumulative error. I
don't know of any, offhand, but I can confirm that what you're doing in
the case you listed is correct.
If only Patricia Shannahan (Did I spell that right?) was still following
this newsgroup.... She was the best I ever saw at explaining how
floating-point types work in the real world. Unfortunately, her web
page doesn't have anything about the topic up.
Andrew Thompson - 22 Apr 2004 22:03 GMT
> If only Patricia Shannahan (Did I spell that right?) ..
No double 'nn', Shanahan.

Signature
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology