File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Adding the values without using arithmentic operators Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Adding the values without using arithmentic operators" Watch "Adding the values without using arithmentic operators" New topic
Author

Adding the values without using arithmentic operators

soma lingam
Greenhorn

Joined: Apr 26, 2007
Posts: 19
How can i add the values from 1 to 10 without using any arithmetic operators.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Why do you want to do this?
Is it a homework assignment?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bob Good
Ranch Hand

Joined: Jan 09, 2008
Posts: 86
maybe BigDecimal would help.

BigDecimal.add()...

BigDecimal
[ January 31, 2008: Message edited by: Bob Good ]
Petrus Pelser
Ranch Hand

Joined: Feb 20, 2006
Posts: 132
Have a look at the shift and binary operators.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by Petrus Pelser:
Have a look at the shift and binary operators.


The question is NOT to use any operators!


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Bob Good
Ranch Hand

Joined: Jan 09, 2008
Posts: 86
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

Joined: Oct 02, 2003
Posts: 11155
    
  16

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...


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding the values without using arithmentic operators
 
Similar Threads
Comparing with bitwise operators
examination question
doubt in >>> operator in negative numbers
bitwise addition of two integers
Swapping through shift operators ?