Ruby : Math

Posted on April 21, 2008. Filed under: Uncategorized |

Math is a module which has a lot of useful Methods.

To convert from one class to another just call the class name followed by parameter.

Integer(field)

Float(field)

String(field)

All other method are applied on the object itself like 3.div 3 or 12.divmod 5 which divides and gives the balance. or you can remainder to get the remainder alone.

you can question the number just like normal language like

.zero? .nonzero? .infinity? .finite? .nan? .integer? .float? .ciel .floor .round .next .chr .log .sqrt .exp .length

To get constants since it is a Module Math::PI

Prime numbers : Prime.new : p.next,p.succ.

Make a Comment

Make a Comment: ( None so far )

blockquote and a tags work here.

  •  

    April 2008
    M T W T F S S
    « Mar   Jun »
     123456
    78910111213
    14151617181920
    21222324252627
    282930  
  • My Fav

Liked it here?
Why not try sites on the blogroll...