DEC64 Is the Wave of the Past

Own C.J.S. Hayward's complete works in paper!

Arbitrary precision arithmetic libraries are old hat. But this is different.

View project on GitHub.

This is a proof of concept, and only a proof of concept, for an approach that will allow exact precision arithmetic for any computable number. Want the square root of three to three decimal places? Realize later-on that the user wants twenty decimal places instead, or that the number of decimal places is dynamic? No need to refactor the original calculation; just ask the stored square root of three for twenty, or a user-supplied number, of decimal places. Have algorithms to calculate e and π? Add e and π together, and don't worry until later about how many decimal places you want for e + π. Numbers are stored with exact precision and decimal approximations are print-on-demand.

The approach is outlined in the original email:

I was thinking about a way to try to have integer-clean arithmetic on algebraic numbers, and a brief Google search for "integer-clean arithmetic algebraic numbers" did not turn up obvious software tools for integer-clean handling of algebraic numbers.

However, I think I may have found a way to use objects to circumvent the corruption that comes from naive use of floating point numbers, where the corruption can increase exponentially.

Let's say that every number is an object that is either:

  • Something that primitively can return an arbitrarily specified number of digits' accuracy, which includes π and e, eventually, but what I originally have in mind is just integers, which will just return more zeroes after the decimal point if you keep asking for more digits of accuracy. —OR—
  • An object storing a first number, a second number, and an operation between them (addition, multiplication, and exponentiation, and their inverses).

Let us furthermore suppose that each number object has a method to evaluate its contents to a specified accuracy.

Numbers in class should be calculable by querying both numbers with enough additional places of accuracy that, when the operation is performed on them, the error is orders of magnitude smaller than the requested accuracy. (Note that this leaves the door open to some question of rounding error; but if a certain number of digits' accuracy has rounding error that overlaps the rounding for the requested accuracy, more digits might be requested. Rounding error may be a fly in the ointment, although it would seem that an epsilon-delta style argument would establish that there are no corner cases that cannot be met by specifying enough digits.)

So if I request (31 / 10 + the square root of 2), accurate to three decimal places, and we say that we are giving two digits of padding, that resolves first to 31.00000 / 10.00000, round to 3.10000, and the second resolves to 2.00000 ^ .500000, which resolves to 1.41421. I add them, getting 3.51421, which I round to three decimal places, getting 3.514. And nothing in this calculation has been integer clean arithmetic in the usual sense, but the number has been evaluated accurately to three places, and it could just as well have been evaluated accurately to twenty places.

Now this abandons one feature that comes with specification floating-point arithmetic, namely that any number takes O(1) memory. This seems like numbers would have something more like O(n log n) memory, maybe more but seems subquadratic at least. And on a machine with 16 gigs of RAM, there may be some calculations where you want and can afford the memory consumption for these objects. For that matter, 16 megs of RAM might still be enough that you don't absolutely need O(1) floating point numbers.

I think I'll see about a Python package tomorrow.

Thoughts?

P.S. to [Name]: I'm interviewing with Google.

The proof of concept is only intended as a proof of concept, not a production release and not necessarily something that will handle every corner case. However, it is intended to clearly outline how one would go about such things and what the concept is that's being proven.

This is implemented in Python that is written to be executable pseudo-code, (perhaps apart from the laborious parser that takes integer, float, string, and Decimal values and converts them to Numbers built from integers). The code is meant to be not-clever, and serve programmers in other languages as pseudocode that demonstrates how one might go about implementing this approach to arithmetic and number in the language of one's choice.

Download Proof of Concept in Python.

View Source for Proof of Concept in Python.

The proof of concept, and this page, are licensed to you under your choice of the terms of the MIT and GPLv2 licenses.

This page is link-ware. If you like it, please consider a link to CJSHayward.com.

I Miss Aqua: A Retro-Themed Maverick

Revisited Years Later

This project is one that barely worked, for a time. There was a time when it provided an Aqua-themed virtual machine with a live web browser. Since then updates have undone most Aqua theming. More problematically, the one (then) current browser I could find that would work under Maverick Meerkat was a developer's build of Firefox, which didn't have to pull in the web of newer dependencies that practically anything else would, and that newer browser became astonishingly unstable, much worse than Internet Exploder 6. The main reason I am keeping it around, besides the fact that I can't foresee all of my visitors' needs, is that it provides the least geeky way to access the programming project I cut my teeth on programming, an arcane game called The Minstrel's Song.

Since then I have purchased one of (then) ten copies of Snow Leopard Server available on Amazon, the one OSX version where you are allowed to run on a virtual machine, and it has the Aqua look and feel. I've actually had to use some of the same skills; an older Chrome installs but will not update, and I had to do some juggling to get LibreOffice 4.3.3 installed. All the same, it's nice to have that option now open. (And use the installed Terminal.app without Sierra's epic instability in the built-in command line.)

I've been trying to find a way to get Aqua back on my Mac, and getting Aqua to display under any OS has been a trackless waste. But I've been able to stitch something together (nothing new) to offer a Linux old enough to display old Aqua themes and "look and feel" appropriately, while running a modern version of Firefox. And now it's here.

Some people regard the Aqua theme as done and gone, and passé. It's out of the Mac mainstream at any rate, and has been for the past couple of releases of Mac OSX.

But with a little help from VMware and a little open sourced Linux theming magic, it's possible to get Aqua back:

This configurable and nostalgic blast from the past, made available through customizable themable Linux, provides a small treat for people who liked the good old days of Mac Aqua. And it is available on all of Windows, Linux, and Mac: search for the free VMware Player, VMware Workstation, or VMware Fusion from the VMware site.

Download the "I Miss Aqua" virtual machine and network appliance now!

Ajax without JavaScript or Client-Side Scripting

The Ajax application included in this page implements a legitimate, if not particularly useful or even usable, "proof of concept" with partial page updates based on server communication. It accepts a string, and then lets you click on one of a few buttons to see that string styled the way the button is styled, appending a link from the server. But it demonstrates one interesting feature:

It works just the same if you turn off JavaScript and any other client-side scripting completely.

How does it work?

Ajax partial page updates don't need to manipulate a monolithic page's DOM; the reason browser back buttons work in Gmail is an invisible, seamless use of iframes that create browser history. And not only can you do partial page updates via iframes without DOM manipulation, you can do it without client side scripting.

The source code to the server is available here, but it is simple, stateless, and doesn't really hold any secrets; it could be fairly well reconstructed simply by observing what is going on in the demo app above. The basic insight is that a webpage that talks to a server and makes partial updates can be made by the usual Ajax tools, but at least a basic proof of concept can be made with old HTML features like frames and iframes, links and targets, forms, and meta refresh.

This Ajaxian use of old web technologies may or may not produce graceful alternatives to standard Ajax techniques, either alone or in a "progressive enhancement"/"graceful degradation" strategy, but it may allow graceful degradation to be just a little more graceful, and JAWS might at least know when something on the sceen has changed. But here is a proof of concept that it is possible to implement a webapp with partial page updates and server communications that works in a browser that has JavaScript and any other client-side scripting turned off.