This week's book giveaway is in the Agile and Other Processes forum.We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!See this thread for details.
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
• Devaka Cooray
• Ron McLeod
• Paul Clapham
• Liutauras Vilda
Sheriffs:
• paul wheaton
• Jeanne Boyarsky
• Tim Cooke
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Tim Moores
• Mikalai Zaikin
• Carey Brown
Bartenders:

# k&b page no. 231

Ranch Hand
Posts: 39
• Number of slices to send:
Optional 'thank-you' note:
hey,
in last example down the page the code is
Long l2= Long.parseLong("101010" , 2);

my question is that does string 101010 reflect 52 in decimal (book shows it to be 42)???

Ranch Hand
Posts: 513
• Number of slices to send:
Optional 'thank-you' note:
Hi Deepesh,

101010 is 42 in binary:

0 x 2^0 = 0
1 x 2^1 = 1
0 x 2^2 = 0
1 x 2^3 = 8
0 x 2^4 = 0
1 x 2^5 = 32

1 + 8 + 32 = 42

Here's a concise intro to binary if you're unfamiliar with the notation:
[ November 09, 2007: Message edited by: Kelvin Lim ]

deepesh mathur
Ranch Hand
Posts: 39
• Number of slices to send:
Optional 'thank-you' note:

Originally posted by Kelvin Lim:
Hi Deepesh,

101010 is 42 in binary:

0 x 2^0 = 0
1 x 2^1 = 1
0 x 2^2 = 0
1 x 2^3 = 8
0 x 2^4 = 0
1 x 2^5 = 32

1 + 8 + 32 = 42

Here's a concise intro to binary if you're unfamiliar with the notation:

[ November 09, 2007: Message edited by: Kelvin Lim ]

IS THIS REALLY EQUAL TO 42
i mean
DON'T YOU HAVE MADE A SILLY CALCULATION MISTAKE???

1 + 8 + 32 = 42
it should be
2 + 8 + 32 = 42
(SORRY IF IT HURTS)
but anyways thanks...

author
Posts: 9050
21
• Number of slices to send:
Optional 'thank-you' note:
be nice Deepesh!

deepesh mathur
Ranch Hand
Posts: 39
• Number of slices to send:
Optional 'thank-you' note:
Sorry bert, kelvin
but really i must admire you are a genius
who is not only encapsulated in a bunch of java code
but is a real warrior...
seeking forgiveness )

regards
DEEPESH
[ November 10, 2007: Message edited by: deepesh mathur ]

Kelvin Chenhao Lim
Ranch Hand
Posts: 513
• Number of slices to send:
Optional 'thank-you' note:
Umm, see, I was just making sure you really read my reply! Yeah, that's it!

Anyway, no worries, Deepesh. No offense taken at all. I'm just glad to be able to help out once in a while.

 Where does a nanny get ground to air missles? Protect this tiny ad: a bit of art, as a gift, that will fit in a stocking https://gardener-gift.com