Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
how do i parse in a double?
Author Message
Homer_simpson

Posted: Fri Feb 13, 2004 1:52 pm   Post subject: how do i parse in a double?

how do i parse in a double?

wtd

Posted: Fri Feb 13, 2004 5:36 pm   Post subject: (No subject)

See my post in this thread.

http://www.compsci.ca/v2/viewtopic.php?t=3632
Homer_simpson

Posted: Fri Feb 13, 2004 8:16 pm   Post subject: (No subject)

well if u'd looked at that post closely u'd see that i've got 2 posts in there... and it doesn't work... but thx for response...
but anyway i figured how to do it... u can just use Double.valueOf to parse it in...
Dan

Posted: Fri Feb 13, 2004 10:28 pm   Post subject: (No subject)

thats odd,

Double.parseDouble(String)

works for me, same with it's int equivlent. are u using an unstandered java lib or somting?
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Homer_simpson

Posted: Fri Feb 13, 2004 11:28 pm   Post subject: (No subject)

yes but there's a difference between Double and double...
Paul

Posted: Fri Feb 13, 2004 11:32 pm   Post subject: (No subject)

Hacker Dan wrote:
thats odd,

Double.parseDouble(String)

works for me, same with it's int equivlent. are u using an unstandered java lib or somting?

Thats always what I used too, I just didn't wanna post, cause i wasn't sure, since Homer already posted this on the other help thread, so I thought if he knew about it...
Oh and I thought double was just a kind of a variable that can have decimals, you know... when you declare it its double, but when you use it in that line its Double, just like parsInt. Im not sure though.
wtd

Posted: Fri Feb 13, 2004 11:59 pm   Post subject: (No subject)

In Java not everything is an object. Most things are, but there are also some basic types:

• char - not like char in C-based languages, where char is one byte. In jaa char is 2 bytes (to accomodate unicode).
• short - 6 bit integer.
• int - 32 bit integer.
• long - 64 bit integer
• float - single precision (32-bit) floating point number
• double - double precision (64-bit) floating point number

These are passed by value, rather than by reference, a behavior that's quite often expected to be correct.

The problem is that there are lots of places in Java that only objects can go, so most of those types, including double, are also classes, though in Java-style, the class name begins with a capital letter.

Since Java doesn't support operator overloading (except in the String class, and you'll have to talk to Sun about that one), you can't have code like:

 code: Double d = new Double(4.2); d = d - 2.5;

Though I don't know how this holds up now that Java 1.5 features auto-boxing.

I hope that helped you understand the difference between "Double" and "double".
Homer_simpson

Posted: Sat Feb 14, 2004 2:30 am   Post subject: (No subject)

yes and Double isn't just a variable type... it's a full class with a lotta constructors... veryuseful...