Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created June 4, 2022 13:18
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 lizmat/42d59853c1dfe1f3df35e379b7043efc to your computer and use it in GitHub Desktop.
Save lizmat/42d59853c1dfe1f3df35e379b7043efc to your computer and use it in GitHub Desktop.
simple scientific notation
sub simple-science($value) {
my ($counter,$multiplier) = $value.fmt("%e").split("e");
$counter.subst(/ 0+ $/)
~ ' x 10'
~ $multiplier.subst(/^ . <( 0+ /).trans('+-0123456789' => '⁺⁻⁰¹²³⁴⁵⁶⁷⁸⁹');
}
dd simple-science(.42);
dd simple-science(42);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment