Results 1 to 6 of 6
  1. #1
    ryanmk54's Avatar
    ryanmk54 is offline Member
    Join Date
    May 2011
    Posts
    18
    Rep Power
    0

    Default scaing a BigDecimal to float

    Is there a way to set the scale of a BigDecimal to float?

  2. #2
    Jodokus's Avatar
    Jodokus is offline Senior Member
    Join Date
    Jan 2011
    Location
    Amsterdam, the Netherlands
    Posts
    230
    Rep Power
    4

    Default

    Did I go into all that trouble just to let you convert it back to a float? :confused:
    square rooting a BigDecimal
    No bug ever had to calculate its fitnessfunction.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,522
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by ryanmk54 View Post
    Is there a way to set the scale of a BigDecimal to float?
    You obviously haven't read the API documentation for the BigDecimal class; hint: BigDecimal extends the Number class and the Number class defines and abstract method floatValue(); the BigDecimal class has to define it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    ryanmk54's Avatar
    ryanmk54 is offline Member
    Join Date
    May 2011
    Posts
    18
    Rep Power
    0

    Default

    Quote Originally Posted by Jodokus View Post
    Did I go into all that trouble just to let you convert it back to a float? :confused:
    square rooting a BigDecimal
    I don't mean to make you feel like I'm wasting your time, but as for now, my calculator will only be set to give floats. In a future version, your method will come in very, very, useful.

  5. #5
    Jodokus's Avatar
    Jodokus is offline Senior Member
    Join Date
    Jan 2011
    Location
    Amsterdam, the Netherlands
    Posts
    230
    Rep Power
    4

    Default

    Thank you. Don't be bothered by my grumbling. I liked the subject.
    (See the other tread...)
    No bug ever had to calculate its fitnessfunction.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Don't use float when you can use double since double is much more precise than float without hardly any more overhead (BigDecimal on the other hand has a much larger overhead than either double or float). The only exception that I can think of is with core methods or classes that require float, such as when working with Stroke.

Similar Threads

  1. Negating a BigDecimal
    By ryanmk54 in forum New To Java
    Replies: 5
    Last Post: 05-16-2011, 06:23 PM
  2. Divide bigdecimal again
    By ellhar in forum New To Java
    Replies: 3
    Last Post: 03-23-2011, 10:19 AM
  3. BigDecimal and BigInteger
    By jon80 in forum New To Java
    Replies: 8
    Last Post: 11-28-2010, 11:15 AM
  4. Using BigDecimal
    By doymand in forum New To Java
    Replies: 2
    Last Post: 10-30-2010, 09:25 AM
  5. BigDecimal question
    By orchid in forum New To Java
    Replies: 2
    Last Post: 08-12-2008, 01:44 PM

Tags for this Thread

Posting Permissions

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