Results 1 to 3 of 3
  1. #1
    nengkya is offline Member
    Join Date
    Apr 2017
    Posts
    2
    Rep Power
    0

    Default BigDecimal number = BigDecimal.valueOf(base, scale);

    How to understand this script, Sir ? Tysm in advancce. (y)

    package helloworldapp;

    import java.math.BigDecimal;

    public class HelloWorldApp
    {

    public static void main(String[] args)
    {

    long base = 12345;
    int scale = 4;
    BigDecimal number = BigDecimal.valueOf(base, scale);
    System.out.println(number);
    BigDecimal pointRight = number.movePointRight(5);
    System.out.println(pointRight + "; my scale is " + pointRight.scale());
    BigDecimal scaleBy = number.scaleByPowerOfTen(5);
    System.out.println(scaleBy + "; my scale is " + scaleBy.scale());

    }

    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: BigDecimal number = BigDecimal.valueOf(base, scale);

    How to understand this script
    Please edit the program and write comments on each line describing what the statement on that line does.
    If you have a specific question about a statement, ask.

    Please wrap the new code in code tags to preserve its formatting.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    398
    Rep Power
    5

    Default Re: BigDecimal number = BigDecimal.valueOf(base, scale);

    The sample is probably trying to show you that the 2nd line and the 4th line from the bottom come up with the same result.

Similar Threads

  1. About BigDecimal
    By dojob in forum New To Java
    Replies: 12
    Last Post: 08-05-2013, 12:00 PM
  2. Replies: 1
    Last Post: 05-19-2012, 09:39 AM
  3. BigDecimal
    By tarka in forum New To Java
    Replies: 4
    Last Post: 11-12-2011, 08:22 PM
  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

Posting Permissions

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