On Tue, Mar 10, 2009 at 5:37 AM, Kerr Rainey <[email protected]> wrote: > 2009/3/9 Noah Slater <[email protected]>: >> My company produce price feeds using decimals, and we need those decimals to >> be >> decimals. For that reason, and after much messing about and research, I >> decided >> that we should use strings for all non-int numerical values. I would be >> supportive of a canonicalisation format that followed this rationale. > > I've had good results using a scheme where decimals are made up of > pairs of ints, the first representing a coefficient and the second a > power of 10. Basically calculator e notation, but with an integer > instead of a float, adjusted accordingly. >
I like this idea - I wonder if we can get serialize it to a valid JSON string - I think 235e-2 works ... checking.... yes it does! I've started working on a butchering of json2.js that gives a canonical form for a given JavaScript object. I'm doing test-driven development, and so far I've got it passing just a few of the basics. (And the float handling is not as good as Kerr's). You can run the tests here - ignore the messiness of my copy of Futon, those spinners will never stop. http://jchrisa.net:5984/_utils/couch_tests.html?/canon/_design/canon/tests.js The source code is at http://github.com/jchris/canonical-json I bet we can get this thing working this week! Chris -- Chris Anderson http://jchris.mfdz.com
