• Post Reply Bookmark Topic Watch Topic
  • New Topic

excess 128 notation  RSS feed

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
lol ok, could someone explain how to get the number

+123 in this notaion...

and then -35...

please,


thanks,

Justin
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never heard of excess notation before today. But Google is our friend as always: CS 200 notes on Excess Notation
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Override the toString() method?




Or make a separate method? Alot easier...

 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To convert a number to excess 128 it looks like you also need to subtract 128. But that's easy, right? As for ensuring there's a '+' for positive numbers, JDK 5 finally offered a compact mechanism for doing this using format strings:

This particular format is also pretty easy to replicate without JDK 5:

however I like to encourage people to learn to use String.format() (and similar methods added to PrintWriter and other classes). They give you a lot more options for formatting things.
[ January 29, 2007: Message edited by: Jim Yingst ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And that helps get these bit patterns?

For example, let's say we want to determine the pattern for 15 in Excess 128 notation. The decimal number would be 128 + 15, or 143. Therefore, the bit pattern would be 10001111. Likewise, -15 would be 128 - 15, or 113. Therefore, the bit pattern would be 01110001.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No - but is that the question? I didn't think so. I thought �dne and I were addressing the one thing not covered in the link you gave: how to get the plus sign. Looking at the table in the notes you linked to, I'm talking about how to get the values in the column labeled "Excess 16", not the column labeled "Binary Pattern". If Justin still has questions, maybe he should clarify what sort of result he's expecting with an example.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!