[4578] in java-interest
Doubles and Math (<> C)
daemon@ATHENA.MIT.EDU (Michael Afergan)
Sun Jan 7 19:33:40 1996
From: mikea@ai.mit.edu (Michael Afergan)
To: java-interest@java.sun.com
Date: Sun, 07 Jan 96 18:01:15 GMT
I have not done a lot with math thus far in my dealings with Java, but
assume that I'm missing something here.
I have a textarea (test) whose value is technically a string.
However, the user will be typing in a number that I want to handle as a
double. I thus choose to use the following statement:
t = new Double(test.getText());
but get the following error:
Calc.java:46: Incompatible type for =. Can't convert java.lang.Double to
double.
t = new Double(test.getText());
^
This leads to a basic problem. Should I define my number variables as
I would in C (i.e., double total, int size) or should I define them with their
official class names (i.e., java.lang.Double total). If I do the later I can
obtain the value from the Textarea, but cannot do other things (namely math)
with the variable. (i.e., t += 5 won't work if t is defined as
java.lang.Double).
While all of this makes sense, I am still uncertain as to how I should
go about obtaining the value and performing standard math operations with it.
Any suggestions and/or comments appreciated.
-- Mike
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com