Numbers in Ruby  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews Ruby
Written by Adi Bach   
Friday, 16 February 2007

{mos_sb_discuss:50} 

Let's play with Numbers. In Ruby, numbers without decimal points are called integers, and numbers with decimal points are usually called floating-point numbers or, more simply, floats (you must place at least one digit before the decimal point). Here's the program rubynumbers.rb


=begin

  Ruby Numbers

  Usual operators:

  + addition

  - subtraction

  * multiplication

  / division

=end


puts 1 + 2

puts 2 * 3

# Integer division

# When you do arithmetic with integers, you'll get integer answers

puts 3 / 2

puts 10 - 11
puts 1.5 / 2.6

Read more

  


User reviews

There are no user reviews for this item.

Add new review




Powered by jReviews

Last Updated ( Friday, 16 February 2007 )
 
< Prev   Next >