formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Slice - 19.10.2010
hey,
This is not another number formatter function. With this, you can format
any variable type without having to change anything. Before you lose interest, allow me to re-attract your interest by providing a bullet-list!
- Set the thousand separator (or disable it)
- Set the number of decimals
- Set the decimal point
- Format hex numbers without getting invalid values on high numbers
More information is inside the include.
Examples:
pawn Код:
new
iNumber = 4864334,
Float:fFloat = 55548623.112,
bool:bFalse = false,
bool:bTrue = true
;
printf( FormatNumber( iNumber ) );
printf( FormatNumber( fFloat, 3, ',', '.' ) );
printf( FormatNumber( bFalse ) );
printf( FormatNumber( bTrue ) );
printf( FormatNumber( fFloat, 0 ) );
printf( FormatNumber( iNumber, 2, 0 ) );
printf( FormatNumber( hex:fFloat ) );
printf( FormatNumber( bit:0b00100110 ) );
printf( FormatNumber( bit_byte:0b10101010101010101010101010101011 ) );
Will print:
Код:
4 864 334
55,548,624.000
false
true
55 548 624
4864334.00
0x4C53E6B4
0b00100110
0b10101010101010101010101010101011
Download!
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
F_Lexx - 19.10.2010
interesting
good idea
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Scenario - 19.10.2010
Not bad, I'm liking this.
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Slice - 19.10.2010
Quote:
Originally Posted by ******
I like your use of tagof!
Also:
pawn Код:
format( s_szReturn, sizeof( s_szReturn ), "%.*f", iDecimals, xVariable );
|
Thanks, I felt kinda awkward about that part. Updated.
I'm quite amazed I got the tagof way working flawless; I'm just starting to realize how useful tagof actually can be.
Edit:
Update
You can now print out either the first 8 bits (using the bit_byte: tag), or all 32 bits (using the bit: tag).
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Seven. - 20.12.2010
awesome..!
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
justsomeguy - 21.12.2010
nice i like it
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
HyperZ - 21.12.2010
Awesome.
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
SWEMike - 09.05.2011
Why not change it from "FormatNumber" to "fnum" or something? ^.^
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Zh3r0 - 09.05.2011
Quote:
Originally Posted by SWEMike
Why not change it from "FormatNumber" to "fnum" or something? ^.^
|
Do that yourself
And since when a name of a function counts so much?
Код:
This forum requires that you wait 120 seconds between posts. Please try again in 1 seconds.
Can't believe that happened O_o
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Slice - 09.05.2011
Quote:
Originally Posted by SWEMike
Why not change it from "FormatNumber" to "fnum" or something? ^.^
|
Cause it's ugly - like your face.
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
justsomeguy - 09.05.2011
Dont talk about his face!!!! He cant help it that his face is ugly!
This forum requires that you wait 120 seconds between posts. Please try again in 1 seconds.
T_T Did....did that just..... realy happend.... to me?
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Slice - 10.05.2011
1 seconds!!!!!!!!
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
BASITJALIL - 10.05.2011
Nice work Slicez
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Joe Staff - 10.05.2011
Why did you include the DB and DBResult tags in the parameter?
EDIT and why not for kicks add in economical punctuation ($1,000,000.00) and chronical format (01:32:500, MM:SS:mmm)
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
SWEMike - 20.05.2011
Quote:
Originally Posted by Slice
Cause it's ugly - like your face.
|
Well, then I suppose fprint is ugly aswell. I was just suggesting a small thing but apparently it's not allowed here.
And you haven't seen my face so you can't really know. :P
I like this include no matter what the name of the function is.
EDIT: "This forum requires that you wait 60 seconds between reporting posts. Please try again in 1 seconds." LOL! : )
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
juraska - 20.05.2011
interesting job.
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
BoBiTza - 26.05.2011
how i make to bank money to make to zecimal?on /stats
Re : formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Myk3l - 26.05.2011
Vert cool
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
aRoach - 27.01.2012
Well, it's a great work, but..
I have a problem:
Код:
..\pawno\include\FORMATNUMBER.inc(112) : error 020: invalid symbol name ""
And:
Код:
else if ( iTag == tagof( hex: ) || iTag == tagof( Hex: ) )
Can you help me ?
Re: formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 ) -
Slice - 27.01.2012
What do you compile it with?