Results 1 to 2 of 2

Thread: Class float

  1. #1
    Peter is offline Senior Member
    Join Date
    Jun 2007
    Posts
    119
    Rep Power
    0

    Default Class float

    In a project that I'm working there is an inputText to input float number and to save it into database,
    But I had a problem. The inputText was binded into an instance of Class Float in Java language, but when I input some number such as 1234567892 and submit it, it converted into 123456792 into database, and when I read it, it shows 1.23456792E8.
    How does it happen? Is there any method to solve this problem to save and show this number as itself(123456789 or 1.23456789E8)?
    Thanks

  2. #2
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    8

    Default

    Convert the String to BigDecimal and save that instead.
    Floating-point types are not adequate for saving decimal numbers with fraction.
    Float's precision of only the first 7 positions explains what happened.

Similar Threads

  1. String to Float
    By durahman in forum New To Java
    Replies: 2
    Last Post: 02-12-2008, 01:17 AM
  2. Float to String
    By mew in forum New To Java
    Replies: 4
    Last Post: 12-29-2007, 06:08 PM
  3. convert string to float
    By miss_dot in forum NetBeans
    Replies: 1
    Last Post: 11-15-2007, 12:26 AM
  4. Error with convert to Float
    By cachi in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 03:18 AM
  5. Help with valid declarations of a float
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 11:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •