Skip to content

New suggested convention for formatting numbers, units and prefixes #55

Closed
@nitro2k01

Description

@nitro2k01

Inspired by PR #54 I would like to suggest the following guidelines for how to write numbers and units:

  1. These conventions should be documented near the top of the document, as needed.
  2. Use the binary prefix ki (kibi) prefix when referring to 1024, and Mi (mebi) prefix when referring to 1024*1024. (Feel free to argue against this point, however. Note: binary prefixes are currently almost not used.)
  3. Capitalize prefixes according to either SI or IEC standards: kilo=k, mega=M, kibi=ki, mebi=Mi. (Note: currently, kilo is fairly consistently capitalized (K) across the document.)
  4. Abbreviate bytes as B when used with a prefix. Spell out bits as bits, even when used with a prefix to avoid ambiguity. (Note: currently byte is fairly consistently written as a full word.)
  5. Find a suitable prefix or suffix to use for hexadecimal numbers. I'm undecided which format should be used, but I'm personally leaning toward standardizing on $ prefix which is used by RGBDS. But either way, let's decide on one and stick with it. (Note: currently it's a mix between Martin's convention of the suffix h, assembler centrix $, c-centrix 0x, and even sometimes x formatted as multiplication sign in running text, which to me just looks very wrong.)
  6. To prevent clutter, don't use a prefix for hex numbers when it's clear from the context that a number is hexadecimal. For example addresses and lists of opcodes. In those cases, zero pad, even for smaller number. (Eg: 0000-3FFF instead of 0-3FFF. Note: Currently the document pretty much follows this guideline.)
  7. Put a space between numbers and their unit. (Note: Currently, memory sizes are often written as 4KB or similar.)
  8. Decimal numbers should be written with a decimal point instead of a comma. (I'm only bringing this up because the physical screen sizes are currently written with a decimal comma.)
  9. Binary numbers: I suspect that it's sufficiently clear from context when a binary number is used. But when/if a prefix is needed, I suggest %, which is what RGBDS is using.

Feel free to discuss or add more suggestions in case I've forgotten some corner case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions