• 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

use of calculator in exam

 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI all
Can we use calculator in exam from binary to decimal conversions
Thanks
candy
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, afraid not.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
candy -
It wouldn't even help if you could! You have to understand two's complement, and if you do you won't need to calculate big old binary numbers.
 
kundan varma
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bert
In ur operator and assignment self test, u r saying 2>>5 is 0 but it should be 2/64=0.03125 as per ur formula.Plz clarify.
Also is there any formula for >>> operator.
Thanks
candy
 
kundan varma
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Bert
If you can throw some light on this, then i will be highly obliged.
Waiting for ur reply
THanks
candy
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by candy varma:
In ur operator and assignment self test, u r saying 2>>5 is 0 but it should be 2/64=0.03125 as per ur formula.


I'm not sure about which formula are we talking about, but here's an explanation:
2 in decimal is 00000010 in binary
Each >> shift "moves" the bits to the right, which leads to
"2 >> 1" = 0000001
"2 >> 2" = 0000000
"2 >> 3" = 0000000
"2 >> 4" = 0000000
etc.
The ">>>" operator works the same way except that when the most significant (sign) bit is moved to the right, the "vacant slots" are filled with zeroes. With ">>" those vacant slots are filled with whatever the sign bit was.
 
Bert Bates
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
candy -
It seems to me Lasse's explanation is a great start - do you understand his answer? It seems that your formula for dividing by 2 to the N isn't really the best way to think about this topic - you really have to look at the binary.
 
kundan varma
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
THanks Lasse and bert for your inputs.
I will sit in this month end for the exam.
THanks again
candy
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bert Bates:
candy -
It seems to me Lasse's explanation is a great start - do you understand his answer? It seems that your formula for dividing by 2 to the N isn't really the best way to think about this topic - you really have to look at the binary.


bit shifting operations are integer operations, not floating point.
Therefore if you take a floating point division to determine the answer you will need to take into consideration as the result ONLY the integer part of the resulting floating point number.
And even then you have to consider that the result is invalid when you're doing a bitshift operation on a negative number.
Examples (using 8 bit ints for brevity).
-1 >> 1 == 10000001 >> 1 == 01000000
-1 >>> 1 == 10000001 >>> 1 == 11000000
Neither of which is equal to -1/2 == -0.5 (the int part of which is -0 )
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jeroen,
I am looking at your shift operation example.
Do you have the results flipped?
Should the results be:
-1 >> 1 == 10000001 >> 1 == 11000000
-1 >>> 1 == 10000001 >>> 1 == 01000000
Cheers, Lawrence
 
On top of spaghetti all covered in cheese, there was this 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