Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created April 3, 2012 14:07
Show Gist options
  • Save phiggins42/2292270 to your computer and use it in GitHub Desktop.
Save phiggins42/2292270 to your computer and use it in GitHub Desktop.
A handy way to convert your dollar values to an unreadable base 16 variant.
function zero(n){
n = n.length == 1 ? n + "0" : n;
return +n;
}
function dollarsToHex(total){
var parts = total.toString(10).split(".");
return parts.map(function(part){
return zero(part).toString(16);
}).join(".");
}
function hexToDollars(hex){
var parts = hex.split(".");
return parts.map(function(part){
return parseInt(part, 16);
}).join(".");
}
@phiggins42
Copy link
Author

(for writing checks. eg: "two hundred and fifty five and 50/100" but in the box you put "$ff.32" ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment