Logo

Programming-Idioms

Calculate the SI (International System of Units) prefix, x, of value a.

For example, 'k', 'M', 'G', 'T', etc.

https://en.wikipedia.org/wiki/Metric_prefix
New implementation

Type ahead, or select one

Explain stuff

To emphasize a name: _x โ†’ x

Please be fair if you are using someone's work

You agree to publish under the CC-BY-SA License

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
x =  case a
  when 1e3... 1e6 ; "k"
  when 1e6... 1e9 ; "M"
  when 1e9... 1e12; "G"
  when 1e12...1e15; "T"
  else ""
end