hl

Saturday, 11 March 2017

Ruby Programming Language Tutorials Lec 03

Tutorial 3

Arithmetic operators :

     To work with the ruby on addition , substraction , multiplication , division and modulus is very simple so lets check it out-

Simply for addition write (6+4) it will work and so substraction , multiplication , division and modulus will also work the same 

                                 Input                                            Output

   










Limit of Integer

     In ruby the limit of the integer is so long it can take value more than 6,611,686,018,427,387,903
This is the longest integer limit till now.

Ruby uses different ways storing integers which allows you basically be able to store numbers
     
      Alright now I will show you some thing about float numbers.In ruby the floating point numbers are also so large  so for example lets make an float number "num_one = 1.0000"
and another float number " num99 = 0.999 " and command it puts num_one.to_s + " + " + num99.to_s + " = " + ( num_one - num99 ).to_s and running it  so lets check it out

Input



Output

It is so accurate upto very very end of its variable up to 20 digits

If we taking an integer big_float = 1.12345678901234 and command it to add the longest float so we can see that it can do calculation up to 14 digit of the decimals by commanding this puts (big_float + 0.00000000000005).to_s . It will show you 1.1234567890123899

                            Input                                                          Output


                                                                             










No comments:

Post a Comment