Ruby: sprintf surprise

Who said weird ?

irb(main):010:0> '%.2f' % (270*1.175)*0.3
=> ""
irb(main):011:0> '%.2f' % ((270*1.175)*0.3)
=> "95.17"

This entry was posted on November 13, 2008 . You can follow any any response to this entry through the RSS feed. You can leave a comment.
Tags:      


Comments

Leave a response

  1. pr4y @ 13 Nov 08:56:

    et si tu fais:

    irb(main):010:0> '%.2f' % (6685*0.5) * 0.4

    irb(main):011:0> '%.2f' % ((6685*0.5) * 0.4)

    tu obtiens la meme chose ?

  2. Christophe @ 13 Nov 13:47:

    Classique :)

Leave a comment