I am using this FormathWithPrefix function with little knowledge about logarithms ... :)
Support SI prefixes .
function FormathWithPrefix(n: double; decimals: integer): string; var index: integer; const Prefixes: array[-9..9]of string = ('<', 'y', 'z', 'a', 'f', 'p', 'n', 'µ', 'm', '', 'k','M', 'G', 'T', 'P', 'E', 'Z', 'Y', '>'); begin index := round((Ln(n) / Ln(10) - 1) / 3); if index > 9 then index := 9; if index < -9 then index := -9; result := (FloatToStrF(n / Exp(index * 3 * ln(10)) , ffFixed, 20, decimals) + Prefixes[index]); end; begin n := 1500; Writeln(FormathWithPrefix(n, 1),'V');
source share