Frances Bea (frances_bea) wrote in suggestions,
Frances Bea

Represent large numbers with interspersed commas

Represent large numbers with interspersed commas

Short, concise description of the idea
Some of the large values on are really easy to misread. With interspersed commas they would be better.

Full description of the idea
I noticed an LJ user commenting that LJ staffers "boast about their millions of users, but less than a million have ever updated." This is a really easy way to misread a number like 8300832, when it's displayed in that format.

All of these numbers should be displayed with interspersed commas. If a comma-fy function were incorporated into the LJ code base, various pages could invoke it with extremely little coding effort.

This function is one I use, and could be a good place to start:

sub commafy {
my $f = shift;
$f =~ s/[^\d\.]//og;
return 0 if ($f == 0);
my ($d, $fract) = split /\./, $f, 2;
return "0.$fract" if (not $d);
my $rem = length($d) % 3;
$d = join '', ( (' ') x (3 - $rem) ), $d if ($rem);
$d = join ',', grep /\d/, split /(...)/, $d;
$d =~ s/^\s*//o;
return "$d.$fract" if ($fract);
return $d;

The function could be much shorter if you remove support for floating point numbers, or much longer if you add internationalization support.

An ordered list of benefits
  • Fewer users will misread various large numbers displayed on the LJ site.
  • Fewer LJ-ers will suspect LJ staffers of telling fish tales when describing the size of LiveJournal. :)

An ordered list of problems/issues involved
  • Not all LJ-ers will have the same understanding of the meaning of commas and periods within numbers. The commafy() function I use would get much more complex if all users are to be well supported.
  • commafy() would have to be judiciously applied, because many computer programs would be confused by numbers containing commas. Only those values intended for human readers should have commas added.

An organized list, or a few short paragraphs detailing suggestions for implementation
  • The commafy() function I listed, or another like it, should be added to an appropriate location so it is available to code generating LJ pages.
  • Calls to commafy() should be added to the code for those pages wherever commas are appropriate, beginning with
Tags: site copy, statistics, § migrated
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded