• 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

Wrapper class Long.toString() method

 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.out.println(Long.toString(15, 16)); is printing f3.
But
System.out.println("---->"+Long.toString(11110011,16)); is not printing F3.Instead it is printing a9867b.what is this value?please help me.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shiva Mohan:
System.out.println(Long.toString(15, 16)); is printing f3.
But
System.out.println("---->"+Long.toString(11110011,16)); is not printing F3.Instead it is printing a9867b.what is this value?please help me.



The first parameter is the long value to be converted to a string. In your case, it is a value of 15 (in decimal format). This should convert to a value of "f" in base 16 format.

In the second case, it is a value of 11110011 (also in decimal format). Which converts to a value of "a9867b" in base 16 format.

Henry
 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Henry for the reply.But I have a doubt.

11110011 is a decimal value.So first convert the decimal value to binary. Then convert it to hexa decimal.I got it.

Conerting 11110011 from decimal to binary value is 101010011000011001111011.The calculation part is goes on the number 5555005.
I don�t know,how to get this number? Help me.
 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here comes more information of my doubt.
11110011 .
/2= 5555005 rem 1
/2= 2777502 rem 1
/2= 1388751 rem 0
/2= 694375 rem 1
/2= 347187 rem 1
/2= 173593 rem 1
/2= 86796 rem 1
/2= 43398 rem 0
/2= 21699 rem 0
/2= 10849 rem 1
/2= 5424 rem 1
/2= 2712 rem 0
/2= 1356 rem 0
/2= 678 rem 0
/2= 339 rem 0
/2= 169 rem 1
/2= 84 rem 1
/2= 42 rem 0
/2= 21 rem 0
/2= 10 rem 1
/2= 5 rem 0
/2= 2 rem 1
/2= 1 rem 0
/2= 0 rem 1

Here, how did the decimal number 11110011 changed to the number 5555005.
 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CAn anyone please help me how to get the number 5555005.
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
5555005 in decimal is
0101 0100 1100 0011 0011 1101 in binary or
-5------4-----c------3-----3-----d in hex
[ August 17, 2006: Message edited by: Campbell Ritchie ]
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and this is 11110011 in binary:-
0000 0000 1010 1001 1000 0110 0111 1011
---0-----0-----a-----9-----8-----6-----7----b in hex.
 
permaculture is largely about replacing oil with people. And one tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic