• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to print Big Integer using for Loop?  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

This is my code I amtrying to iterate a value of L,R both are range of BigInteger but its not working




I am trying to iterate a for loop in range of L and R

but its not working
 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think compareTo() does what you want. I returns a -1, 0, or 1 if the compared number is less than, equal, or greater than the number.
 
Liutauras Vilda
Sheriff
Posts: 4923
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When you say "its not working". What do you mean by that?

1. Are you getting compile time error? (if yes, please write down all compile time errors you're getting)
2. Your program not working as you expected? (if yes, how it should work?)

Beside that, it would be strange if this piece of code would work, as it is not full. Please explain more.

 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, maybe it's what you want, but you have to use it differently.

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This link
http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#compareTo(java.math.BigInteger)


Helped me to solve

Thansk @Knute
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!