# Binary and Hexadecimal numbers question.

**URL:** <https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476>\
**Category:** Factual Questions\
**Created:** [March 31, 2004, 5:42am UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476 "2004-03-31T05:42:56Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![sturmhauke](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sturmhauke](https://boards.straightdope.com/u/sturmhauke)\
**Post date:** [April 1, 2004, 8:23pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/21 "2004-04-01T20:23:52Z")

</div>

I want to see pi expressed in Mayan glyphs, or cuneiform.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [April 1, 2004, 9:13pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/22 "2004-04-01T21:13:41Z")

</div>

> [@sturmhauke](#):
>
> I want to see pi expressed in Mayan glyphs, or cuneiform.

You can’t use normal methods for representing fractions in systems that don’t use positional notation, so cuneiform is right out.

---

<div class="post-metadata">

**Author:** ![Shade](https://avatars.discourse-cdn.com/v4/letter/s/2bfe46/32.png) [@Shade](https://boards.straightdope.com/u/Shade)\
**Post date:** [April 1, 2004, 9:18pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/23 "2004-04-01T21:18:00Z")

</div>

You could draw a circle and write ‘this ratio’…

> [@](#):
>
> Why isn’t there an equivalent binary point and hexidecimal point? For example, for hex numbers .1 would be 1/16, .01 would be 1/32, \*[1/256]\*and so on.

You’ve just shown you _can_. You should instead ask “Why is this rarely seen?” to which the answer is “binary is most often seen representing values in bytes which always used to be integers” or something.

The idea crops up in mathematics occasionally, and even more exotic forms, where each digit is in a different base!

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [April 1, 2004, 9:21pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/24 "2004-04-01T21:21:53Z")

</div>

> [@Bytegeist](#):
>
> As **Sturmhauke** and others have mentioned, FPU registers are implemented in binary, not decimal. This is what gives the “flaky” numeric behavior that surprises so many beginning programmers — that 5 divided by 10 is not necessarily 0.5, for example, but might be 0.499999997 instead.

It gets worse. For suitable numbers a, b, and c, a + (b + c) != (a + b) + c.

---

<div class="post-metadata">

**Author:** ![sturmhauke](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sturmhauke](https://boards.straightdope.com/u/sturmhauke)\
**Post date:** [April 1, 2004, 10:34pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/25 "2004-04-01T22:34:40Z")

</div>

> [@ultrafilter](#):
>
> You can’t use normal methods for representing fractions in systems that don’t use positional notation, so cuneiform is right out.

Right, forgot about that. Those Sumerians didn’t make their clay tablets very Y2K compliant either, I bet.

---

<div class="post-metadata">

**Author:** ![Nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@Nobody](https://boards.straightdope.com/u/Nobody)\
**Post date:** [April 2, 2004, 2:39am UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/26 "2004-04-02T02:39:48Z")

</div>

> [@r\_k](#):
>
> Wouldn’t 0.01 in hex be 1/256?

Whoops, you’re right. My mistake :o

---

<div class="post-metadata">

**Author:** ![engineer\_comp\_geek](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/engineer_comp_geek/32/504_2.png) [@engineer\_comp\_geek](https://boards.straightdope.com/u/engineer_comp_geek)\
**Post date:** [April 3, 2004, 5:54pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/27 "2004-04-03T17:54:57Z")

</div>

> [@Master Control](#):
>
> Are you saying that FPU calculations are just as fast as CPU integer calculations? I still thought that, even to this day, integer calculations were faster because FPU commands take a few lines of code to execute even a simple command. I mean, it has to unpack the exponent and mantissas and then… Anyway, I still assume that integer calculations are much quicker.

Back in the days of the 486, floating point operations took significantly longer to execute than integer instructions. These days the difference in speed isn’t quite as bad, but that’s not saying that floating point instructions execute as quickly as integer instructions. Integer instructions are still faster.

There is no “unpacking” required in floating point operations, just different circuitry required to execute the instructions. The co-processor works off of a stack model (you push data onto the floating point stack, perform the operation, and pull the data back off of the stack) which has a bit more overhead than an integer instruction. Pentiums are able to optimize integer instructions more than floating point just because integer operations are simpler.

---

<div class="post-metadata">

**Author:** ![Nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@Nobody](https://boards.straightdope.com/u/Nobody)\
**Post date:** [April 3, 2004, 6:29pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/28 "2004-04-03T18:29:53Z")

</div>

> [@engineer\_comp\_geek](#):
>
> Back in the days of the 486, floating point operations took significantly longer to execute than integer instructions. These days the difference in speed isn’t quite as bad, but that’s not saying that floating point instructions execute as quickly as integer instructions. Integer instructions are still faster.
> 
> There is no “unpacking” required in floating point operations, just different circuitry required to execute the instructions. The co-processor works off of a stack model (you push data onto the floating point stack, perform the operation, and pull the data back off of the stack) which has a bit more overhead than an integer instruction. Pentiums are able to optimize integer instructions more than floating point just because integer operations are simpler.

Oh, I see.

I’ve seen code for doing floating point math and figured that the FPU operated similary. Partially because I’ve heard in the past that FPU commands are more like code than simple commands, and also because of the fact that they’re a little more complicated.

I mean, with integer 1 + integer 1 you just add the two togeather to get 2  
But with float 1 - IEEE 00111111100000000000000000000000 you can’t go 1 + 1  
Which would give you 01111111000000000000000000000000  
instead of 2, which is 01000000000000000000000000000000

Anyway, I’m rambling, but thanks for clearing some of that up for me 🆒

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [April 3, 2004, 6:46pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/29 "2004-04-03T18:46:17Z")

</div>

Some folks have asserted that decimal numbers aren’t handled directly by CPUs. Not always true.

The Intel IA-32 (ie 386 through current Pentium) processors have a decimal format that stores numbers in RAM as decimal digits and the load/store instructions convert them to floating point for actual computation in the FPU.

Mainframes, in particular the long-serving IBM 360/370/390 architecture have instructions for performing native artihmetic on decimal-coded integers, in addiciton to the more common binary integer & binary floating point formats.

Finally, many data formats use fixed-point non-integers. That is to say the math is done using integer circuitry but the results are interpretted as numbers with a fixed number of bits/digits to the left and the right of the radix point. The common example is currency, where you can think of $1.25 as either one-and-one-quarter-dollar, or as 125 pennies. Do all the math in integer numbers of pennies and then shift the radix point 2 places for display.

That method gives you integer speed and avoidance of roundoff errors, while preserving the user expectation of 2 decimal places.

---

<div class="post-metadata">

**Author:** ![sturmhauke](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sturmhauke](https://boards.straightdope.com/u/sturmhauke)\
**Post date:** [April 3, 2004, 7:39pm UTC](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476/30 "2004-04-03T19:39:29Z")

</div>

[Binary Coded Decimal](http://www.tpub.com/neets/book13/53s.htm)

Each decimal digit is represented by a 4-bit string, or nibble. The bit patterns that would normally represent the hex digits a-f are not considered valid in BCD. It’s not like normal binary, but it’s not exactly like decimal as a human would use it either. Plus it’s inefficient memorywise, because you usualy need more bits than regular binary to represent the same number.

[Previous page](https://boards.straightdope.com/t/binary-and-hexadecimal-numbers-question/237476.md?page=1)
