Here you can find the source of numberToFloat(Number n)
public static Float numberToFloat(Number n)
//package com.java2s; //License from project: Apache License public class Main { public static Float numberToFloat(Number n) { if (n != null) { if (n instanceof Integer) return ((Integer) n).floatValue(); else if (n instanceof Float) return ((Float) n); else if (n instanceof Double) return ((Double) n).floatValue(); else if (n instanceof Short) return ((Short) n).floatValue(); else if (n instanceof Long) return ((Long) n).floatValue(); else//from w w w.j ava 2s . c om return (Float) n; } return null; } }