4 Replies - 2139 Views - Last Post: 06 January 2010 - 03:42 AM Rate Topic: -----

#1 car2nistrob   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-December 09

How to?

Post icon  Posted 03 December 2009 - 12:36 PM

I'm trying to figure out how to make a simple calculator in Ruby? :blink:
Is This A Good Question/Topic? 0
  • +

Replies To: How to?

#2 EdwinNameless   User is offline

  • D.I.C Addict
  • member icon

Reputation: 128
  • View blog
  • Posts: 723
  • Joined: 15-October 09

Re: How to?

Posted 03 December 2009 - 01:57 PM

View Postcar2nistrob, on 3 Dec, 2009 - 11:36 AM, said:

I'm trying to figure out how to make a simple calculator in Ruby? :blink:



What have you got so far? What type of calculator are you trying to do? Coz you can do the following:

[email protected]:~$ irb
irb(main):001:0> 4*5
=> 20
irb(main):002:0> 6-7
=> -1
irb(main):003:0> 4/5
=> 0
irb(main):004:0> 4.0/7.0
=> 0.571428571428571



so you can use irb as a calculator... :P
Was This Post Helpful? 0
  • +
  • -

#3 car2nistrob   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-December 09

Re: How to?

Posted 03 December 2009 - 02:16 PM

View PostEdwinNameless, on 3 Dec, 2009 - 12:57 PM, said:

View Postcar2nistrob, on 3 Dec, 2009 - 11:36 AM, said:

I'm trying to figure out how to make a simple calculator in Ruby? :blink:



What have you got so far? What type of calculator are you trying to do? Coz you can do the following:

[email protected]:~$ irb
irb(main):001:0> 4*5
=> 20
irb(main):002:0> 6-7
=> -1
irb(main):003:0> 4/5
=> 0
irb(main):004:0> 4.0/7.0
=> 0.571428571428571



so you can use irb as a calculator... :P


I didn't have any code written yet, but what I am doing is trying to teach myself how to do this. I want to make a simple calculator that will add, subtract, multiply, divide and work out the power of integers. I'll worry about floats later.
Was This Post Helpful? 0
  • +
  • -

#4 QuackWare   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 02-January 10

Re: How to?

Posted 02 January 2010 - 11:44 AM

You might want to look at these Ruby math operators code samples and they might help you out.
Was This Post Helpful? 0
  • +
  • -

#5 Guest_elizas*


Reputation:

Re: How to?

Posted 06 January 2010 - 03:42 AM

Hi,
this is Eliza. The following links might be help to answer your question
http://jameswilliams.be/blog/entry/157
Was This Post Helpful? 0

Page 1 of 1