Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding the values without using arithmentic operators

 
soma lingam
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i add the values from 1 to 10 without using any arithmetic operators.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to do this?
Is it a homework assignment?
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe BigDecimal would help.

BigDecimal.add()...

BigDecimal
[ January 31, 2008: Message edited by: Bob Good ]
 
Petrus Pelser
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the shift and binary operators.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Petrus Pelser:
Have a look at the shift and binary operators.


The question is NOT to use any operators!
 
Bob Good
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BigDecimal.add()is a method not an operator.

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/opsummary.html
[ January 31, 2008: Message edited by: Bob Good ]
 
fred rosenberger
lowercase baba
Bartender
Posts: 12123
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Raghavan Muthu:
The question is to NOT use any operators!


i believe it was to not use any ARITHMETIC operators. I'm not sure a bit shift counts as one of those...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic