Java examples for java.lang:Math Calculation
Calculate the order of magnitude of a number (float by now)
//package com.java2s; public class Main { /**/*w ww . ja va2 s . co m*/ * Calculate the order of magnitude of a number (float by now) * * @param range the input string * @return the resulting order */ public static int getOrderOfMagnitude(int range) { int aux = range; int mag = 1; while (aux > 10) { mag = mag * 10; aux = aux / 10; } ; return mag; } }