Monday, April 24, 2017

Paradise ponders: rain, and strange coincidences edition...

Paradise ponders: rain, and strange coincidences edition...  It is pouring on us right now (see the radar snapshot at right).  I'm up in my barn office, and the noise of the rain hitting the steel roof over my head is deafening.

This morning I spoke for a little while with the attorney I'm using to handle a real estate transaction in Virginia.  He mentioned that he was a little familiar with Utah, as he used to come out here for vacations, especially near Moab.  So I shared a bit with him about our numerous trips there, and I mentioned that we knew the La Sal Mountains very well.  He then related his happy visits to Pack Creek Ranch, a now-defunct resort on the western slopes of the La Sals.  Debbie and I have very happy memories of that place, having stayed there several times ourselves.  It's a little bitty resort, way out of the way, exactly our sort of place precisely because it's not very popular.  And yet ... this lawyer from Virginia knew it, and had stayed there three or four times.  What a bizarre coincidence!

A step taken...

A step taken...  This morning I registered a new domain: decinum.org.  I was a bit surprised that it hadn't already been taken – my usual experience with finding domain names is that the first 1,000 or so that I try have already been snagged. :)  Further, to my amazement, 60 seconds after registering decinum.org, the DNS resolution was already working.  The first domain I ever registered (dilatush.com, back in '93) took several days to get that far.

This new registration is a first step for an open source project I'm going to start working on.  The main purpose is to actually implement the observations and ideas I've had for representing money in Java.  The vast majority of that work lies in representing high precision decimal numbers, hence the domain name.  I won't have any web site for decinum.org at first; I locked down the name mainly so I could safely use it for Java class names...

Sunday, April 23, 2017

Paradise ponders, 8' lumber, oven removal, and scallops edition...

Paradise ponders, 8' lumber, oven removal, and scallops edition...  Tomorrow we're supposed to get our new oven installed.  You may remember that we gave up on our old oven after three failed attempts to get it repaired.  The new one is a Bosch model that we're hoping we're just as happy with as we are with our Bosch dishwasher.  Also, it came highly recommended by our repair technician.

So this morning I tackled what I thought was likely to be an all-day job: removing the old oven and installing an electrical junction box.  The house's previous owner had done an awesomely shabby job of wiring the old oven: he just used wire nuts to join the wires, covering them with approximately eight miles of electrical tape.  It's the sort of electrical job you might imagine a child doing.  I ran into something similar when I replaced the microwave directly above this oven, and there I had room to install a standard outlet box.  The new oven is 220V, and those outlets are way too big to install in the cramped space the oven must fit in.  So I went with a hard-wired junction box.

Taking the oven out turned out to be relatively easy.  I had the old oven out in our garage just a half hour after starting.  With some creative use of our hand truck, it wasn't even all that difficult.  The hardest part was getting it onto the hand truck – wrangling 185 lbs of oven by myself was a bit of a challenge!  But I got it...

We made a run to Home Depot and got all the electrical parts I needed.  Installing them took all of another half hour.  So by 10 am I was completely done with that job.  Yay!

So we made another run to Home Depot, this time to buy the stuff I needed to build out a couple of frames around two of our basement windows in our cattery.  These are the windows that we've opened up to our sun room.  I removed the glass sliding windows, including their frame, and now we just have the steel frame that's set into the basement's concrete wall.  I'm building a frame out of cedar 1x8's with the boards perpendicular to the plane of the old window.  This is at the suggestion of our mason, who will use that frame as one edge of the rock he's installing.

I needed to buy five 8' long pieces of cedar (1x8s), so I did some measuring to see if it would be possible to fit those in our Model X.  To my surprise, the answer was yes!  About six inches of the boards needed to extend over the center console, which I covered with a shipping pad to protect.  The photo at right I took while standing behind the open rear hatch.  You can see the “hole” between the two front seats where we stowed the boards, along with the pads I used to protect it.  We keep getting surprised by what we can carry in the Model X – it's really quite roomy inside (especially our five seat version with the rear seats folded down).

On the way to Home Depot, I stopped for a few groceries at Smith's.  That's not where we usually shop, so while I was in there I did a little scouting.  On the way by the seafood counter I spotted scallops – the great, big sea scallops that Debbie uses in her scrumptious baked scallops recipe.  I bought a pound and a half, and Debbie is cooking them as I write this.  Feast today!

Saturday, April 22, 2017

Jaw-dropping innumeracy test...

Jaw-dropping innumeracy test...  I ran across this online somewhere (can't find it now), read their results and suspected shenanigans.  I was wrong.  In fact, my own tests suggest the innumeracy situation might even be worse than the report I read.

Here's the test:
Take a piece of blank paper.  Draw a dot on the left and mark it “0”.  Draw a dot opposite the first one, on the right, and mark it “1,000,000,000” (one billion).  Draw a line between the two dots.  That's a number line, like many of us learned in school.  It represents all the numbers between zero and a billion, with the integers equally spaced.  Now draw a third dot on the line where you think the number 1,000,000 (one million) belongs.
The report I read said that about half of people trying this test put the third dot in roughly the correct place; everyone else got it wrong.  That's the result I was skeptical of.  The correct place, of course, is 1/1000th of the line's length from the left.  So if your line was 10 inches long, the third dot would be a mere 1/100th of an inch from the dot for zero.

So I've tried the test now on five people (a ludicrously small sample, I know), more or less randomly selected.  None of them were even remotely close to the right answer.  The most common place for the third dot was somewhere near the middle of the line.  One person put it about 1/5th of the line's length from the right!  I'm slightly comforted by the fact that none of these people were scientists or engineers ... but only slightly comforted. 

I find this absolutely stunning.  Somehow it never occurred to me that so many adults – probably a majority of adults – wouldn't intuitively grasp such basic concepts.  That level of innumeracy means that things like discussions of government budgets are beyond their ken, as they don't understand the significance of the difference between millions, billions, or trillions of dollars (and probably not thousands, either!).  Or basic astronomical concepts.  Sheesh, much of science involves numbers covering multiple orders of magnitude. 

Gobsmacked, I am...

Paradise ponders, brief “I’m busy!” edition...

Paradise ponders, brief “I’m busy!” edition...  Yesterday none of our workers showed up, and no progress was made on any project.  I hate days like that!

I squired Debbie down to Ogden for her hair appointment, which took 3.5 hours.  She does this every five weeks, so that works out to roughly 40 hours a year.  Me, I get a haircut every 5 or 6 months, whether I need it or not. :)  My haircuts generally take less than 15 minutes.  My haircuts cost $15, including a 50% tip (which the ladies who cut my hair are very happy with!).  Debbie's cost ... you don't want to know, especially if you include the cost of the chemical soup she buys to maintain it.  Now, I like her hair, mind you.  I'm just noting the differences here, and pondering the magnitude of the investment of time and treasure.  I cannot even imagine doing this myself...

When we were done with her hair appointment, we tried out a new restaurant in Ogden: Rosa's Cafe.  We found it through Yelp.  Debbie ordered a smothered pork burrito, and I had a chili relleno.  Both were outstanding – they had a home-cooked vibe, much like our beloved Los Primos.  The portions were gigantic, especially that burrito.  Even better, the staff (allegedly a family) were just as friendly as the folks at Los Primos.  We knew it was going to be good when we first opened the door.  Debbie stood there for a moment, trying to figure out how to negotiate the small step up into the restaurant.  An ample young man who works there stepped out to help with a big smile, and simply lifted her right up.  Problem solved!  An older man guessed that this was our first time, and advised us on what to get based on our tolerance for spiciness.  We placed our order, grabbed some mango Jarritos from the fridge (again, just like Los Primos), and sat down to wait.  Less than five minutes later, our food was in front of us.  Mine came with rice and refries, and both of those were also outstanding – as was the giant, thick flour tortilla that came with the meal.  That tortilla was obviously homemade for those burritos.  The beans are made there, and man can you tell.  The rice is something that most Mexican restaurants don't do well, with the rice typically grossly overcooked.  Not here.  The rice was perfect, the sauce beautifully done, and just the right amount of corn, carrots, etc.  You can probably guess that we'll be going back. :)

Why am I busy today?  I'm catching up on two weeks of neglected financial stuff.  It's been accumulating in a pile on my desk, and today I shall demolish that pile...

Friday, April 21, 2017

Paradise ponders, filling stations, muddy dogs, and wet weather ahead edition...

Paradise ponders, filling stations, muddy dogs, and wet weather ahead edition...  Well, the guys were here on Wednesday working on our filling station, and now the interior plumbing is ever-so-close to being finished.  All that's missing now is a piece of channel steel to hold the upper pipes firmly in place no matter how hard we tug on the hoses, and a wooden assembly (which I'll build) to hold the nozzles.  On the other end of the plumbing, they have yet to connect the pipes to the tanks; I'm expecting that to happen today.  Yesterday I took all the measurements of the front opening, drew up a diagram, and sent it off to Lazy K Wrought Iron to get a quote for them to make us a door.  The day before I sent off the specifications for a railing on our sun room steps, and the stanchions for our deck railing.  We're going to keep those folks busy for a while!

Thursday we got most of an inch of rain, mainly in the morning.  That means our property is muddy, even where there's grass, as the ground was already completely saturated from past rains.  The dogs this morning provided the proof (as if we needed any): when I let them back in after their morning outing, they were all little mud-balls.  Now our forecast (click left to embiggen it) shows an entire week with good chances of precipitation.  If you add all those days up, that's well over an inch of additional rain coming.  Man, we're going to be wet!  All that precipitation will fall on saturated ground, both here in the valley and up in the mountains.  That means our streams will fill rapidly each time there's rain – not quite the flash floods we saw in California's deserts, but fast enough you could observe it over the course of just a few minutes.  Our reservoirs are all chock-full and already overflowing prodigiously, so if these rains actually materialize I suspect we'll be in for some more flooding.

Next Tuesday a working steam locomotive will be stopping for a half hour in Cache Junction.  That's just a short distance south of my brother's cabin, about a half hour's drive from our home.  I'm hoping that Debbie and I can make it up there to see it!  Here's more about the No. 844 locomotive, and its 2017 schedule.

It's now 10 days since Debbie had the hardware removed from her knee, and she's recovering nicely.  There was a fairly big incision, and her healing process this time is all about that.  She can already put most of her weight on her left knee (the one that was operated on).  That incision was closed with staples, and they come out next Wednesday.  Once that happens, Debbie should be unleashed on the physical therapy process.  So far as we know now, she'll be doing that entirely on her own.  We're going to ask next week whether she should have a professional physical therapist work with her on it...

And speaking of Debbie...  She can't quite drive on her own yet, as she needs a bit of help getting in and out of the car.  But she has a hair appointment today, down in Ogden.  So I will be playing chauffeur for part of the day, to get her down there and back.  :)  We'll most likely eat out somewhere while we're down there – wouldn't want to miss the opportunity!

Thursday, April 20, 2017

Prehistoric computing...

Prehistoric computing...  Ken Shirriff does his usual incredibly nerdy computing archaeology...

Tough choices...

Tough choices...  The algorithmic trading server I worked on a few years ago used three different numeric types to represent quantities of money (all USD, in its case).  We used scaled integers (32 bit scaled by 100) to represent stock prices (trades, bid, and ask) because that was known to be sufficient precision for the task and was fast because those integers are native types.  We used scaled longs (64 bits scaled by 10000) for foreign exchange prices (also trades, bid, and ask) for the same reasons.  Finally, we used BigDecimal (Java's built-in decimal with arbitrary precision) for aggregate calculations because it was the only built-in decimal type with enough precision, and because calculations like that were relatively infrequent and the performance penalty wasn't too bad.

But using several different types for the same logical purpose had very bad consequences for our system's reliability.  Why?  Because on every calculation involving money in the entire system, the programmer had to carefully think about the operands, make sure they were in the same value representation, convert them correctly if not, do the calculation, then convert the result (if necessary) to the desired type.  At the same time, the programmer had to correctly anticipate and handle any possible overflow.

So how bad could that be?  Here's a real-world example from that same algorithmic trading server.  Periodically we would look at the bid/ask stack for particular stocks within 5% of the last trade price.  For a highly liquid stock that might involve several thousand entries, where each entry was a price and a quantity.  We needed to get the sum of the extended price for each entry, and then an average price for the ask stack and separately for the bid stack.  The prices were in scaled integers, the quantities also in integers - but their product could exceed what could be held even in our scaled longs.  So we had to convert each price and each quantity to a BigDecimal, then do the multiplication to get the extended price.  Then we had to sum all those extended prices separately for the bid and ask stack.  We could sum the quantities safely in a long, so we did.  Then we had to convert that summed quantity to a BigDecimal so we could divide the sum of extended prices by the summed quantity.  The result was a BigDecimal, but we needed a scaled integer for the result – so we had to convert it back.  That means we needed to (very carefully!) check for overflow, and we also had to set the BigDecimal's rounding mode correctly.  Nearly every step of that process had an error in it, due to some oversight on the programmer's part.  We spent days tracking those errors down and fixing them.  And that's just one of hundreds of similar calculations that one server was doing!

Ideally there would be one way to represent the quantity of money that would use scaled integers when feasible, and arbitrary precision numbers when it wasn't.  It's certainly possible to have a single Java class with a single API that “wrapped” several internal representations.  This is much easier if the instances of the class are immutable, which would be good design practice in any case.  The basic rule for that class at construction time would be to choose the most performant representation that has the precision required.  We could have used such a class on that algorithmic trading server, and that would have saved us many errors – but none of us thought of it at the time...

Note: this is the last post of this series on representing and calculating monetary values in Java.  I've provided a link for the series at right.  If perchance some other semi-coherent thought occurs to me, I reserve the right to add to this mess...