Hi,
I would like to be able to round up any number to quater of the whole number.
For example:
100.33 -> 100.50
100.12 -> 100.25
100.66 -> 100.75
100.99 -> 101.00
100.70 -> 100.75
100.00 -> 100.00
100.25 -> 100.25
etc...
thank guys... 
...
            
           
          
            
            Hello,
Hoping to get some feedback from someone more experienced here. I haven't dealt with the dreaded floating-point calculation before...
Is my understanding correct that with Ruby BigDecimal types (even with varying precision and scale lengths) should calculate accurately or should I anticipate floating point shenanigans?
All my va...
            
           
          
            
            If you specify your ActiveRecord column type to be decimal, Rails will return that database value as a ruby BigDecimal object.
My question is, when working with these fields and performing additional math on them, should I always use BigDecimal values in my calculations or are floating point values ok to use. I didn't know if it is a go...
            
           
          
            
            Is there any way to convert a BigInteger into a BigDecimal?  i know you can go from DEC to INT but i cant find a method to go the other way around in JAVA.
thanks in advance.
...
            
           
          
            
            Hi All,
I have a BigDecimal currency value that needs to be converted to a 6 byte BCD value in cents with leading zeros for a lower level protocol I'm interfacing with.  Anyone have any cunning implementations for doing this?
TIA,
Fred
...
            
           
          
            
            I have a BigDecimal object, myNumber, with unknown length. For example: 12345678. 
I always want to divide this number by 1 million, so I do:
myNumber.divide(BigDecimal.valueOf(1000000))
I get 12.345678. 
I want to display this as a string "12.345678", without cutting off ANY decimal places. 
So I do
myNumber.divide(BigDecimal.val...
            
           
          
            
            new BigDecimal("37146555.53880000").divide(new BigDecimal("1000000")).scale()
This returns 10. But according to the API, the divide method:
  Returns a BigDecimal whose value is
  (this / divisor), and whose preferred
  scale is (this.scale() -
  divisor.scale());
So in this case, 37146555.53880000's scale is 8, and 1000000's scale...
            
           
          
            
            I have a BigDecimal field amount which represents money. And I need to print its value in the browser in format like $123.00, $15.50, $0.33.
How can I do that?
(Еhe only simple solution which I see myself is getting floatValue from BigDecimal and then using NumberFormat to make 2 digits presision for the fraction part).
...
            
           
          
            
            When I insert 78.9 into Mysql (using JDBC) it gets rounded up to 79? Is this normal ... if so how can I stop this from happening.
More details:
Column name: num
Data type: decimal(12,0)
* The above item was copied from phpMyAdmin
Query is
stmt.executeUpdate("INSERT INTO triples(sub_id, pro_id, num) VALUES("+subId+","+proId+",78.9)");...
            
           
          
            
            Hi guys,
Here is the java code 
usageType = (String) c.getSrcValue("USAGETYPE");
c is a arraylist.
I populate it with this field from DB.
 "USAGETYPE" NUMBER(*,0), 
I get the following error 
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to String
Can you please help me out
...
            
           
          
            
            In my little project I need to do something like Math.pow(7777.66, 5555.44) only with VERY big numbers. I came across a few solutions:
- Use double - but the numbers are too big
- Use BigDecimal.pow but no support for fractional
- Use the X^(A+B)=X^A*X^B formula (B is the remainder of the second num), but again no support for big X or bi...
            
           
          
            
            I am trying to make a BigDecimal from a string. Don't ask me why, I just need it! This is my code: 
Double theDouble = new Double(".3");
System.out.println("The Double: " + theDouble.toString());
BigDecimal theBigDecimal = new BigDecimal(theDouble);
System.out.println("The Big: " + theBigDecimal.toString());
This is the output I get?
...
            
           
          
            
            I'm trying to read some BigDecimal values from the string. Let's say I have this String: "1,000,000,000.999999999999999" and I want to get a BigDecimal out of it. What is the way to do it?
First of all, I don't like the solutions using string replaces (replacing commas etc.). I think there should be some neat formatter to do that job fo...
            
           
          
            
            In my app, I handle numbers as BigDecimal and store them as NUMBER(15,5). Now I'd need to properly check on Java if the BigDecimal values would fit the column, so that I can generate proper error messages without executing the SQL, catching exceptions and verifying the vendor error code. My database is Oracle 10.3, and such errors cause ...
            
           
          
            
            I just switched my Ruby version to 1.9.2, and the BigDecimal code works in Ruby 1.8 doesn't working anymore. Here is test code show what happened
irb(main):001:0> require 'bigdecimal'
=> true
irb(main):002:0> (BigDecimal.new("1")/BigDecimal.new("3")).to_s("F")
=> "0.33333333"
irb(main):003:0> (BigDecimal.new("1", 20)/BigDecimal.new("3",...
            
           
          
            
            How to convert from float to bigDecimal  in java?
...
            
           
          
            
            What is the difference between this two call? (Is there any?)
// 1.
new BigDecimal("3.53456").round(new MathContext(4, RoundingMode.HALF_UP));
// 2.
new BigDecimal("3.53456").setScale(4, RoundingMode.HALF_UP);
...
            
           
          
            
            Actually, I've found possible solution 
//returns true
new BigDecimal ("5.50").doubleValue () == new BigDecimal("5.5").doubleValue ()
Of course, it can be improved with something like Math.abs (v1 - v2) < EPS to make the comparison more robust, but the question is whether this technique acceptable or is there a better solution?
If so...
            
           
          
            
            What is the maximum number of digits we can have after the decimal point of a BigDecimal value in Java?
...
            
           
          
            
            Hi,
I have Hibernate method which returns me a BigDecimal.
I have another API method to which I need to pass that number but it accepts Integer as parameter. I cannot change return types or variable types of both methods. 
Now how to convert the BigDecimal into Integer and pass it to second method?
Is there a way out of this?
...