IntCmpU $1 1000 "" "" "kB"
FileWrite $0 "$4;$1Bytes;$1$\r$\n"
Goto tornai
kB:
IntOp $2 $1 / 1024
IntCmpU $2 1000 "" "" "MB"
FileWrite $0 "$4;$2kB;$1$\r$\n"
Goto tornai
MB:
IntOp $2 $2 / 1024
IntCmpU $2 1000 "" "" "GB"
FileWrite $0 "$4;$2MB;$1$\r$\n"
Goto tornai
GB:
IntOp $2 $2 / 1024
FileWrite $0 "$4;$2GB;$1$\r$\n"
Goto tornai does a poor job (it writes 4888bytes as 4kB, at least it should write 5kB). I wanted to do it better but I don't get anything clear from IntFmt and that page from MSDN. I wanted to write one decimal for MB and GB, but as we work with integers i don't know If nsis can do such a thing.
note: $4 is username, $2 is prefixed number, $1 is bytes.