I cannot find any pattern rounding off doubles in an array. I am trying to make a program that will input a double like grades,money etc., and round it off in a whole number.
            Asked
            
        
        
            Active
            
        
            Viewed 1,534 times
        
    0
            
            
        - 
                    I don't know Java but I find this for you - http://stackoverflow.com/a/153753/1542290 so ain't sure how you didn't find any patterns – Mr. Alien Oct 08 '14 at 12:06
- 
                    31) itterate trough array and round your number, 2) dont use doubles for money – user902383 Oct 08 '14 at 12:06
2 Answers
0
            
            
        There are no short cut available, You need to iterate through the array and use Math#floor or Math#ceil or Math.round to round off.
Math#ceil - Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.
Math#floor - Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.
Math#round - Returns the closest int to the argument, with ties rounding up
 
    
    
        Subhrajyoti Majumder
        
- 40,646
- 13
- 77
- 103
 
     
    