Author Topic: Fractional grain amount  (Read 735 times)

Offline tommymorris

  • Brewmaster General
  • *******
  • Posts: 2100
  • Tommy M.
    • View Profile
Fractional grain amount
« on: August 13, 2015, 03:20:37 AM »
I ordered 1 lb 12 oz of Munich malt from Austin Homebrew.

My invoice shows:

"Amount: 1, Fractional Amount: 0.7500001875000468"

I hope they measure the fractional portion correctly. I wouldn't want to get short changed.

S. cerevisiae

  • Guest
Re: Fractional grain amount
« Reply #1 on: August 13, 2015, 04:16:29 AM »
I ordered 1 lb 12 oz of Munich malt from Austin Homebrew.

My invoice shows:

"Amount: 1, Fractional Amount: 0.7500001875000468"

I hope they measure the fractional portion correctly. I wouldn't want to get short changed.

That's bizarre because 0.75 is not one of the fractions that cannot be represented in binary floating point, and there's no way that their scale has that kind of precision.

Offline yso191

  • Senior Brewmaster
  • ******
  • Posts: 1805
  • Yakima, WA
    • View Profile
Re: Fractional grain amount
« Reply #2 on: August 13, 2015, 04:35:54 AM »
I ordered 1 lb 12 oz of Munich malt from Austin Homebrew.

My invoice shows:

"Amount: 1, Fractional Amount: 0.7500001875000468"

I hope they measure the fractional portion correctly. I wouldn't want to get short changed.


That's bizarre because 0.75 is not one of the fractions that cannot be represented in binary floating point, and there's no way that their scale has that kind of precision.

Gosh I wish I could say stuff like that and know what I meant.
Steve
All Hands Brewing
BJCP #D1667

S. cerevisiae

  • Guest
Re: Fractional grain amount
« Reply #3 on: August 13, 2015, 05:56:54 AM »
Gosh I wish I could say stuff like that and know what I meant.

The problem with computers is that they can only count to two.  We have ten unique symbols in our number system (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9).  That's why our number system is called decimal.  When we get to ten, we move over to the next position, and write 10, which is equal to 1 * 10 + 0.  What we are doing is working with powers of ten. The number 200 is equal to 2 * 102  + 0 * 101 + 0 * 100.  There are only two symbols in a computer's number system; namely, 0 and 1.  This number system is known as binary (bit is a contraction for binary digit).  When a computer evaluates 1 + 1, it produces 10, which is two in binary because the places to the left of the first digit are powers of two.  For example, the number 31 in binary is 11111, which is equal to 1 * 24 + 1 * 23 + 1 * 22  + 1 * 21 + 1 * 20, or 16 + 8 + 4 + 2 + 1. 

Non-computer-type forum members are probably asking why a computer uses binary.  Well, the number 1 is most often denoted by 5 volts (there are types of digital logic that use a smaller voltage for the number 1) and the number zero is denoted by 0 volts (actually there are voltage thresholds in most circuits with an ambiguity zone between the thresholds, but let's keep things simple).   One of the simplest circuits in a computer is a half adder.  It is composed of an XOR gate and an AND gate.  The XOR gate produces the sum, and the AND gate produces the carry into the next position.  The truth tables for these operations are as follows

Code: [Select]
A  B   A XOR B
0  0      0
0  1      1
1  0      1
1  1      0


A  B   A AND B
0  0      0
0  1      0
1  0      0
1  1      1
 


Now, there is a circuit called a subtractor, but we do not need it.  We can subtract numbers by representing a negative number in a form known as 2s complement.  In order to convert a positive number to a negative number in 2s complement form, we invert all bits (1s become 0s and 0s become 1s) and add 1.

Example

Let's represent 31 as an 8-bit binary number

00011111

If we want to convert this number to -31 in binary, we first invert all of the bits, leading to

11100000

then we add 1

11100000 + 1 = 11100001

Now, watch what happens when we add 11100001 (-31) to 00011111 (31)

Code: [Select]
11100001
00011111
-----------
00000000


Remember, a computer can only count to 1.  If we add 1 + 1, we get 10; hence, the first two 1s in the two numbers sum to 10, leading to a carry into the next position, which also results in the sum of 10.  This process ripples across the addends.

Now, getting to fractions.  If the positions to the left of the decimal point are powers of two, then the positions to the right of the decimal point are one over powers of two.

0.1/21 + 1/22 + 1/23 +  1/24 + 1/25 ...

The fraction 0.75 is equal to 1/21 + 1/22 (i.e.,  1/2 + 1/4), or 0.11

There are fractions that cannot be handled easily using this system such as 1/10th.  I will not go into detail here, but trust me, these fractions result in repeating binary sequences.

« Last Edit: September 23, 2015, 01:53:03 AM by S. cerevisiae »

Offline yso191

  • Senior Brewmaster
  • ******
  • Posts: 1805
  • Yakima, WA
    • View Profile
Re: Fractional grain amount
« Reply #4 on: August 13, 2015, 06:12:02 AM »
I'm tempted to repeat myself.  I'm just glad someone gets it.  I would feel stupid but I know most people feel the same way when I start talking theology.
Steve
All Hands Brewing
BJCP #D1667

Offline tommymorris

  • Brewmaster General
  • *******
  • Posts: 2100
  • Tommy M.
    • View Profile
Re: Fractional grain amount
« Reply #5 on: August 13, 2015, 11:44:22 AM »
Mark's talking his theology...

S. cerevisiae

  • Guest
Re: Fractional grain amount
« Reply #6 on: August 13, 2015, 02:15:07 PM »
Steve,  believe it or not, the Navy taught me most of this stuff when I was only eighteen years old back when most people had never seen a computer let alone used one.  Navy "A" School was so intense and so scary that I found college and graduate school to a breeze in comparison after leaving active duty.  We used to have a saying, "We are going to be IBMs if we do not pass this exam."  The IBM here was an inside joke. It did not stand for International Business Machines.  It stood for Instant Boatswain's Mate.  :) 

For those who are unfamiliar with naval service (Steve knows this stuff well), the Navy refers to occupations as ratings and rank as rates.  One is not considered to be rated in a rating until one advances to third class petty officer.   Below that rate, one is either a designated or non-designated striker.   A designated striker is usually someone who enlisted with a school guarantee and completed at least "A" school.  A large proper subset of those who enlist without a school guarantee and/or fail to complete "A" school end up as non-designated strikers on the deck force filling a role that is affectionately known as "Deck Ape."   A Deck Ape is a non-rated Boatswain's Mate.  To put things as simply as possible, being a Deck Ape can be a less than pleasant experience (lots of "chipping and painting" and other non-pleasant tasks), which is why many Deck Apes who manage to stay out of trouble eventually strike for a different rating.

Offline Phil_M

  • Senior Brewmaster
  • ******
  • Posts: 1706
  • Southern Maryland
    • View Profile
Re: Fractional grain amount
« Reply #7 on: August 13, 2015, 03:23:02 PM »
Mark, I've been trying to explain 2's comp to someone at work, and might use your explanation.

I really not a fan of working with computers and software. The one exception to that is working at the binary level, which can be a LOT of fun.
Corn is a fine adjunct in beer.

And don't buy stale beer.

Offline yso191

  • Senior Brewmaster
  • ******
  • Posts: 1805
  • Yakima, WA
    • View Profile
Re: Fractional grain amount
« Reply #8 on: August 13, 2015, 04:55:21 PM »
To put things as simply as possible, being a Deck Ape can be a less than pleasant experience (lots of "chipping and painting" and other non-pleasant tasks), which is why many Deck Apes who manage to stay out of trouble eventually strike for a different rating.

Haha!  I told my recruiter that I wanted to drive the small boats.  "You want to be a Boatswain's mate!" he cried.  A year later I became a signalman.  Boatswain's mates are the ships janitors.  Yes they are also the true seamen in terms of doing actual nautical stuff, but the ratio was not sufficiently slanted toward seamanship to keep me.
Steve
All Hands Brewing
BJCP #D1667

Offline santoch

  • Brewmaster
  • *****
  • Posts: 887
  • North Bend, WA
    • View Profile
    • WAHA
Re: Fractional grain amount
« Reply #9 on: September 07, 2015, 08:08:05 PM »
One of my very favorite courses in college started with us using Boolean algebra via truth tables (what S. C just did), taught us combining them using Karnaugh maps, how to wire up that logic using transistor gates, adding more and more complex all the way through burning eproms and building a little 4bit microprocessor with 1K of addressable RAM by the end of the course.  It was awesome.

Mt. Si Brewing Society
Washington Homebrewer's Association (WAHA)
BJCP GM2/Mead Judge

S. cerevisiae

  • Guest
Re: Fractional grain amount
« Reply #10 on: September 22, 2015, 04:14:05 PM »
The K-map is a simple, but powerful tool for the minimization of sum-of-products logic. 

Offline Slowbrew

  • Brewmaster General
  • *******
  • Posts: 2431
  • The Slowly Losing IT Brewery in Urbandale, IA
    • View Profile
Re: Fractional grain amount
« Reply #11 on: September 22, 2015, 06:12:28 PM »
Unless I'm remembering this wrong, you really don't want to mispronounce "Boatswain" either.   ::)

Think Bosun not boat-swain.

Paul.
Where the heck are we going?  And what's with this hand basket?