1 package org.bukkit.util;
9 public static int floor(
double num) {
10 final int floor = (int) num;
11 return floor == num ? floor : floor - (int) (Double.doubleToRawLongBits(num) >>> 63);
14 public static int ceil(
final double num) {
15 final int floor = (int) num;
16 return floor == num ? floor : floor + (int) (~Double.doubleToRawLongBits(num) >>> 63);
19 public static int round(
double num) {
20 return floor(num + 0.5d);
23 public static int toInt(Object
object) {
24 if (
object instanceof Number) {
25 return ((Number)
object).intValue();
29 return Integer.valueOf(
object.toString());
30 }
catch (NumberFormatException e) {
31 }
catch (NullPointerException e) {
36 public static float toFloat(Object
object) {
37 if (
object instanceof Number) {
38 return ((Number)
object).floatValue();
42 return Float.valueOf(
object.toString());
43 }
catch (NumberFormatException e) {
44 }
catch (NullPointerException e) {
50 if (
object instanceof Number) {
51 return ((Number)
object).doubleValue();
55 return Double.valueOf(
object.toString());
56 }
catch (NumberFormatException e) {
57 }
catch (NullPointerException e) {
62 public static long toLong(Object
object) {
63 if (
object instanceof Number) {
64 return ((Number)
object).longValue();
68 return Long.valueOf(
object.toString());
69 }
catch (NumberFormatException e) {
70 }
catch (NullPointerException e) {
75 public static short toShort(Object
object) {
76 if (
object instanceof Number) {
77 return ((Number)
object).shortValue();
81 return Short.valueOf(
object.toString());
82 }
catch (NumberFormatException e) {
83 }
catch (NullPointerException e) {
88 public static byte
toByte(Object
object) {
89 if (
object instanceof Number) {
90 return ((Number)
object).byteValue();
94 return Byte.valueOf(
object.toString());
95 }
catch (NumberFormatException e) {
96 }
catch (NullPointerException e) {