This week's book giveaways are in the Refactoring and Agile forums. We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line! See this thread and this one for details.
Gday, Previously I have been trying to find a method easily truncate a double to a fixed number of decimal places, rounding in the traditional grade school style. Tried big decimal classes and all but There was no reaql easy way to get the required end result. What I have implemented and am using (although inefficient) is Multiplying the double by 10^(number of required places + 1), turn into integer,finding the remainder after dividing by 10, adding or subtracting the appropriate amount, turning into a string then manually inserting a decimal point and zeros if required then returning String.toDouble(). This works perfectly but there must be an easier way?. B. Till