Skip to content

Instantly share code, notes, and snippets.

Created October 7, 2015 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/634472baa623d340ca30 to your computer and use it in GitHub Desktop.
Save anonymous/634472baa623d340ca30 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
multi sub ndr(Real $value, Int $radix = 10) {
1 + floor log (1 max abs $value), $radix
}
multi sub ndr(Real @values, Int $radix = 10) {
1 + floor log (1 max [max] @values>>.abs), $radix;
}
say ndr -1234;
say ndr 0xAAAA, 16;
say ndr 0b1010111, 2;
my Real @a = (1,100,1000,-10000);
say ndr (@a, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment