The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Unicode::Fraction - easy generation of UTF-8 fractions

SYNOPSIS

 use Unicode::Fraction qw(fraction);
 say fraction(1,2); # ½
 say fraction(1,12); # ⅟₁₂
 say fraction(35,48); # ³⁵⁄₄₈

DESCRIPTION

This module provides a simple function to print vulgar fractions in UTF-8.

FUNCTIONS

fraction ($num, $denom)

Generate a UTF-8 encoding string representing the given fraction, using the most compact representation available. The standard Unicode glyphs (¼, ½, etc.) are used if possible; failing that, subscripted and superscripted numbers are used (with either the '⁄' or '⅟' glyphs).

Fractions are not normalised, that is, fraction(2,4) is distinct from fraction(1,2).

AUTHOR

Richard Harris <RJH@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Richard Harris.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.