• Post Reply Bookmark Topic Watch Topic
  • New Topic

Integer and Short  RSS feed

 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why do we need the methods like Integer.toBinaryString(5)just for Integer and Long in Java. Integer.toString(5, 2) can do the same thing.

Also, why dont we have a toString methods available for short with two arguments(i.e, with Radix).Is it because we dont cover large range of values using it.

Thank you,
Himalay Majumdar
[ December 09, 2008: Message edited by: Himalay Majumdar ]
 
BV Boose
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
toString(n,radix) and toBinaryString() don't necessarily return the same thing.


outputs:
 
Himalay Majumdar
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its loook like they differ in computing -ve numbers.
I sense just toString(N, radix) is working fine for -ve numbers.

Also, why dont we have a toString method with two arguments available for short i.e, why we have

Long.toString(Long l, int radix)
Integer.toString(Integer i, int radix)

but NOT
Short.toString(Short s, int radix)

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!