hi all,
i do have a form where i enter a float that can have more then 15 fraction digits, due to important rates that need so much digits.
i have no problem to display it from a database.
the problem is when i take this value from the form. if there is more then 17 numbers after the point, the rest is not taken.
(example : 0.123456789123456789 returns me 0.1234567891234567 (89 is missing))
i do use this method to get the form value :
myObj.EOLY=request.getParameter("eoly");
is my number cuted because i do use getParamter that returns a string and not a float or a number ? is getValue different ? what method should i use not to change the number ?
-
getParameter getValue and floats (6 messages)
- Posted by: e d
- Posted on: April 30 2001 10:15 EDT
Threaded Messages (6)
- getParameter getValue and floats by Dan Josephs on April 30 2001 10:48 EDT
- getParameter getValue and floats by e d on April 30 2001 11:20 EDT
-
getParameter getValue and floats by Dan Josephs on April 30 2001 11:22 EDT
-
getParameter getValue and floats by Nathan Bronson on April 30 2001 02:08 EDT
-
getParameter getValue and floats by e d on May 02 2001 04:20 EDT
- getParameter getValue and floats by e d on May 02 2001 05:10 EDT
-
getParameter getValue and floats by e d on May 02 2001 04:20 EDT
-
getParameter getValue and floats by Nathan Bronson on April 30 2001 02:08 EDT
-
getParameter getValue and floats by Dan Josephs on April 30 2001 11:22 EDT
- getParameter getValue and floats by e d on April 30 2001 11:20 EDT
-
getParameter getValue and floats[ Go to top ]
- Posted by: Dan Josephs
- Posted on: April 30 2001 10:48 EDT
- in response to e d
Two suggestions...
First make sure your method for the form is a "post" not a "get". A "get" has a set length of characters that can be passed where a "post" does not.
Second make sure your text input field in the form doesn't have a max length set. There is no reason that the number should be truncated because it is being returned as a string. You should be able to type in a sentence in that same field and each character should be returned. Hope this helps.
dan -
getParameter getValue and floats[ Go to top ]
- Posted by: e d
- Posted on: April 30 2001 11:20 EDT
- in response to Dan Josephs
i have checked your suggestions :
i do use post method
(<form name = "myForm" ACTION="/MyWebApp/servlet/MSSQLpack.GetCookie" METHOD="POST"> ) <-- that's my code
and here is the way i set my input :
<td align="middle"><input name="eom01" value=""> </td>
so both conditions are here. i don't see why it's cuted after the decimal number 17 -
getParameter getValue and floats[ Go to top ]
- Posted by: Dan Josephs
- Posted on: April 30 2001 11:22 EDT
- in response to e d
make sure to put in the type of input ex.
<input type="text" name="whatever" value="">
then try typing in a sentence with more the 17 characters and see if it gets returned correctly. -
getParameter getValue and floats[ Go to top ]
- Posted by: Nathan Bronson
- Posted on: April 30 2001 14:08 EDT
- in response to Dan Josephs
Are you noticing the loss after you convert the result into a double? The double data type only can express about 16 or 17 digits of accuracy because the entire number (including exponent) is packed into 64 bits. Try using a java.math.BigDecimal, which has arbitrary precision.
- Nathan -
getParameter getValue and floats[ Go to top ]
- Posted by: e d
- Posted on: May 02 2001 04:20 EDT
- in response to Nathan Bronson
well in fact i have tested this :
searchResp.EOLY=request.getParameter("eoly");
BigDecimal bd = new BigDecimal(searchResp.EOLY);
out.println(bd);
(searchResp.EOLY is a String)
the result is the same : the number is truncated after the 16 first digits.
the problem may be when i use getParameter, it converts the number into a String, then if i use BigDecimal, it's too late, the number has already been truncated i think.
i maybe forgot to say that i do have the "eoly" parameter in my jsp and i use getParameter("eoly") in my servlet.
any more clues ??
-
getParameter getValue and floats[ Go to top ]
- Posted by: e d
- Posted on: May 02 2001 05:10 EDT
- in response to e d
well i think i've found the solution
i think that the problem is with my databse, SQL server, that only takes 17 digits for a float