Created
October 7, 2015 20:59
-
-
Save anonymous/634472baa623d340ca30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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