• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Integer and Short

 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic