I have a variable of decimal type and I want to check the number of digits before decimal point in it. What should I do? For example, 467.45 should
decimal
467.45
This would be the Java solution
public class test { public static void main(String args[]) { float f = 1.123f; int a = (int) f; int digits = 0; while (a > 0) { digits++; a=a/10; } System.out.println("No Of digits before decimal="+digits); } }