float literals #178

Open
kwando opened this Issue Apr 2, 2012 · 4 comments

Comments

Projects
None yet
4 participants
@kwando

kwando commented Apr 2, 2012

def square(n:float):float
n * n
end

square(2) # does work
square(2.0) # does not work (no method taking double as argument)
square(2f) # does not work either
square(2.0f) # nor does work

Can't find any documentation on this. I need to use floats since the code should interface with OpenGL which uses 32 bit floating point numbers.

@headius

This comment has been minimized.

Show comment Hide comment
@headius

headius Apr 2, 2012

Owner

We do need a literal syntax for floats, as in Java (so this is a valid bug), but for now you can just do an explicit cast:

$ bin/jruby -S mirah -e "puts Float.valueOf(float(1.0))"
1.0
Owner

headius commented Apr 2, 2012

We do need a literal syntax for floats, as in Java (so this is a valid bug), but for now you can just do an explicit cast:

$ bin/jruby -S mirah -e "puts Float.valueOf(float(1.0))"
1.0
@kwando

This comment has been minimized.

Show comment Hide comment
@kwando

kwando Apr 3, 2012

okey, will use this for the moment then.

kwando commented Apr 3, 2012

okey, will use this for the moment then.

@baroquebobcat

This comment has been minimized.

Show comment Hide comment
@baroquebobcat

baroquebobcat Jan 5, 2014

Owner

You don't need the Float.valueOf as the cast by itself works. It'd still be nice to have the syntax though.

Owner

baroquebobcat commented Jan 5, 2014

You don't need the Float.valueOf as the cast by itself works. It'd still be nice to have the syntax though.

@AtomicPair

This comment has been minimized.

Show comment Hide comment
@AtomicPair

AtomicPair Jan 7, 2014

+1. I would second the vote for a simpler literal synatx on floats.

+1. I would second the vote for a simpler literal synatx on floats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment