Question about Stamp lesson
Alex41
Posts: 112
Hello,
I have a question about a lesson in the "What's a Microcontroller?" with the BS2-IC. The version is 2.2.
My question is about the lesson on Page 155.
I understand the concept of scaling and offset, what I don't understand is that the fractional value is multiplied by 256. Why 256? Is there a reason for this specific number? This isn't explained in the book. Or is 256 just a random number that was chosen?
Thanks for any help.
Alex
I have a question about a lesson in the "What's a Microcontroller?" with the BS2-IC. The version is 2.2.
My question is about the lesson on Page 155.
I understand the concept of scaling and offset, what I don't understand is that the fractional value is multiplied by 256. Why 256? Is there a reason for this specific number? This isn't explained in the book. Or is 256 just a random number that was chosen?
Thanks for any help.
Alex
Comments
In the case of the lesson, the "binary point" is being placed between the two bytes of a 16 bit value with the most significant byte containing the integer part and the least significant byte containing the binary fraction.
I partly understand what you are saying. My confusion is that .724 was multiplied by 256 resulting in 185. Wouldn't you want to use a number that would have 256 as the result of the multiplication?
Alex
I answered a similar question in the BASIC Stamps forum the other day. Check out my 6/1/2007 11:53 AM (GMT -7) post here:
http://forums.parallax.com/showthread.php?p=653664
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
What you have is 185/256. Try doing that on a calculator or in long hand and you'll see that it's the same (approximately) as 0.724.