Groups
Groups
Sign in
Groups
Groups
RubyMotion - Ruby for iOS, OS X, and Android
Conversations
About
Send feedback
Help
round() on floats
60 views
Skip to first unread message
Eugene Alfonso
unread,
Sep 27, 2012, 3:59:06 PM
9/27/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubym...@googlegroups.com
Not sure if im just losing my mind or something, but I cant get round() to work on floats.
in RM REPL:
2.3345.round
=> 2
2.3345.round(2)
=> 2.33449935913086
2.3345.round 2
=> 2.33449935913086
in IRB:
2.3345.round
=> 2
2.3345.round(2)
=> 2.33
2.3345.round 2
=> 2.33
Im kinda new to ruby but I imagine this should've work?
Mark Villacampa
unread,
Sep 27, 2012, 8:22:53 PM
9/27/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubym...@googlegroups.com
I've found this bug too, and used cocoa to get arround it:
formatter = NSNumberFormatter.alloc.init
formatter.setNumberStyle NSNumberFormatterDecimalStyle
formatter.setMaximumFractionDigits 1
formatter.setRoundingMode NSNumberFormatterRoundDown
numberString = formatter.stringFromNumber(Value)
Eugene Alfonso
unread,
Sep 28, 2012, 11:20:33 AM
9/28/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubym...@googlegroups.com
You can use this as well:
'%.2f' % 2.3345
Bodacious
unread,
Feb 19, 2013, 10:59:29 AM
2/19/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubym...@googlegroups.com
I'm experiencing this issue in the latest version of RM
Did you file a bug report?
Joffrey Jaffeux
unread,
Feb 20, 2013, 4:11:46 AM
2/20/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubym...@googlegroups.com
Hi,
yes it's a known bug you can find the issue in the RubyMotion's tracker :
http://hipbyte.myjetbrains.com/youtrack/issue/RM-4
Reply all
Reply to author
Forward
0 new messages