Friday, February 02, 2018

All is well with your approximate existence, mate.

In my Business Programming class that I teach, I was putting together a demo for the students to show the precision, or lack thereof, of certain numeric datatypes. The language is VB.Net. Here is the comment that I have in the code:

'To check floating point division (with Single, Double, and Decimal datatypes), take the quotient and multiply it with the divisor to get a very close approximation to the numerator.

'Why an approximation? "Squeezing infinitely many real numbers into a finite number of bits requires 'an approximate representation.'" (Emphasis mine)

'See https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

It was with that thought that I realized, I am not sure that I like that it is an approximation. Yet, we must and do live with approximations all day long. This came to light to me back in 2007 when I started to really keep track of my nutrition. Right away I realized that when recording my intake for each meal and snack the data are not exact but rather a range of values. For example, when you eat an apple (medium 3" diameter (182 g)), is the caloric intake always 95 calories? No. Is it ever? Occasionally. The point is, on most occasions we make decisions based on approximations and not exact amounts. Yet, these estimates are good enough for most of life in time and space. If you are a fan of Crocodile Dundee, remember the exchange between he and Sue when discussing his age?

(SUE) How old are you?
(MICK) Dunno. What year is this?
(SUE) You don't know?
(WALT) Time doesn't mean much up here.The Aborigines don't have calendars.
(MICK) I was raised by the local tribe.I asked one of the tribal elders when I was born, and he said,"In the summertime."


Of course, this did not mean that Crocodile Dundee was not born on a specific day, but rather he didn't know what day that was on a Gregorian calendar. Yet, he lived day-to-day the same as if he had known the exact date. 

Mind you, with computer languages and floating point datatypes, there are safe guards so you can rest assured all is well with your approximate existence.

No comments: