This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Float syntax


On Jan 9, 2011, at 3:40 AM, Helmut Eller wrote:

Is there a syntax for Float.POSITIVE_INFINITY or
Double.POSITIVE_INFINITY?  Or is that somehow the same as +inf.0?

You can always use java.lang.Float:POSITIVE_INFINITY or java.lang.Double:POSITIVE_INFINITY,
but +inf.0 will automagically get converted to a double or float when the situation requires.
You can also explicitly cast it if you want.


#|kawa:1|# +inf.0
+inf.0
#|kawa:2|# (float? +inf.0)
#f
#|kawa:3|# (double? +inf.0)
#f
#|kawa:4|# (*:getClass +inf.0)
class gnu.math.DFloNum
#|kawa:5|# (float? (as float +inf.0))
#t
#|kawa:6|# (double? (as double +inf.0))
#t
#|kawa:7|# java.lang.Float:POSITIVE_INFINITY
Infinity
#|kawa:8|# (as float +inf.0)
Infinity
#|kawa:9|# (define (is-float-infinity? (f ::float)) ::boolean (or (= f java.lang.Float:POSITIVE_INFINITY) (= f java.lang.Float:NEGATIVE_INFINITY)))
#|kawa:10|# (is-float-infinity? +inf.0)
#t
#|kawa:11|# (is-float-infinity? -inf.0)
#t
#|kawa:12|# (gnu.math.DFloNum:asDFloNumOrNull java.lang.Float:POSITIVE_INFINITY)
+inf.0


-Jamie

--
Jamison Hope
The PTR Group
www.theptrgroup.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]