Click to See Complete Forum and Search --> : Java equivalent of VBScript Int()


TMG77
05-02-2006, 02:26 PM
Hello. I am looking for a function in Java that performs the same task as the Int() function in VBScript. The Int() function returns the integer part of a specified number.

Examples:
document.write(Int(6.83227))Output:6
document.write(Int(6.23443))Output:6
document.write(Int(-6.13443))Output:-7
document.write(Int(-6.93443))Output:-7

Thanks to anyone with any suggestions.

russell
05-02-2006, 02:58 PM
floor() and ceil() are the closest. you could easily write your own int() or fix() function which would return the floor for positive numbers and the ceil for negative numbers. Check out the Math Class Function Reference (http://java.sun.com/j2se/1.3/docs/api/java/lang/Math.html)

TMG77
05-02-2006, 03:18 PM
Thanks russell. That's perfect.