0

I'm not sure. This the right way to calculate percentage ?
Here's my method

public class percent extends Operation {

    @Override
    public Value calculate(Value key, Value value) {

     //BigDecimal result = key.getValue().divide(Value.hundred, Value.SCALE, BigDecimal.ROUND_UP);
       return new Value((key.getValue().divide(value.getValue()).multiply(Value.hundred)));
     //  return new Value(result);




    }

    @Override
    public String getSymbol() {
        return "%";
    }


}

**// means doesn't work as well

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by enterpise
0

My short course of percent calculation:

  1. 1 =100% <=> 1% = 0.01
  2. Percent calculation does not exist, it is just multiplication.

Everything else follows from these two facts.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.