[Include] formatnumber.inc - Human-readable numbers ( 10000000 -> 10 000 000 )
#21

Well, I'm glad that I've helped you to find a 'problem', I think...

So, for a moment ( until you will fix SSCANF ) I will delete that part of code, because it's running without it too...
Reply
#22

An optional currency sign would be rather useful. You can't just do this:

pawn Код:
format(string, sizeof(string), "$%s", NumberFormat(-123456789));
Because you'll get numbers like:

$-100,000,000

The - should be right at the beginning. I know it's not hard to make a function that simply inserts a dollar sign after the - (or at the beginning of the string if no - is there), but I feel as though a function called FormatNumber should also be able to format the number into a currency. Would be more efficient than creating another tack-on function too.

Love your work!
Reply
#23

Good Format numbers For SACNR Blacklite !!!
Reply
#24

Hey guys...

I Added the include to my gamemode

pawn Код:
new money;
//money is my 10% from my hand money but see this error
new amount =  money*10/100;
                            format(str2,sizeof(str2),"%d",FormatNumber(amount));//here i did
                            SendClientMessage(playerid, COLOR_WEAKBLUE, str2);

Error: C:\Users\HP\Desktop\Files\Server\pawno\include\for matnumber.inc(113) : error 020: invalid symbol name ""


Line 113 in include: else if ( iTag == tagof( hex: ) || iTag == tagof( Hex: ) )
Reply
#25

What other include files do you use?
Reply
#26

Quote:
Originally Posted by Slice
Посмотреть сообщение
What other include files do you use?
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <YSI\y_ini>// this is amazing for save Files
#include <foreach>
#include <streamer>
#include <AirBreak>
#include <moneyhax>
#include <dini>
#include <core>
#include <vplate>
#include <formatnumber>
Reply
#27

Quote:
Originally Posted by ******
Посмотреть сообщение
Pretty sure this was determined to be a conflict with sscanf (see previous posts).
#define hex:%0;unformat(_:EXTRZ:EXTRX:%1); %0;unformat(_:EXTRZ:EXTRX:%1);
where should i put this bro?
Reply
#28

I fixed a small bug: when i format -100000 it will return: -,100,000

The fix:
Replace this line in formatnumber.inc
pawn Код:
if ( ++s_iSepPos == 3 )
With this:
pawn Код:
if ( ++s_iSepPos == 3 && s_szReturn[s_iChar-1] != '-' )
Test script:
pawn Код:
new i = 0;
    while(i < 210000000)
    {
        i += random(9) + 1;
        printf("formatted: %s", FormatNumber(i, 0, ','));
        printf("formatted: %s", FormatNumber(i * -1, 0, ','));
       
        i *= 10;
    }
Output:
Код:
[17:08:51] formatted: 4
[17:08:51] formatted: -4
[17:08:51] formatted: 46
[17:08:51] formatted: -46
[17:08:51] formatted: 469
[17:08:51] formatted: -,469 <------- ???
[17:08:51] formatted: 4,694
[17:08:51] formatted: -4,694
[17:08:51] formatted: 46,945
[17:08:51] formatted: -46,945
[17:08:51] formatted: 469,455
[17:08:51] formatted: -,469,455 <------- ???
[17:08:51] formatted: 4,694,558
[17:08:51] formatted: -4,694,558
[17:08:51] formatted: 46,945,588
[17:08:51] formatted: -46,945,588
Fixed version:
Код:
[17:09:05] formatted: 3
[17:09:05] formatted: -3
[17:09:05] formatted: 31
[17:09:05] formatted: -31
[17:09:05] formatted: 314
[17:09:05] formatted: -314 <------- fixed
[17:09:05] formatted: 3,146
[17:09:05] formatted: -3,146
[17:09:05] formatted: 31,461
[17:09:05] formatted: -31,461
[17:09:05] formatted: 314,615
[17:09:05] formatted: -314,615 <------- fixed
[17:09:05] formatted: 3,146,158
[17:09:05] formatted: -3,146,158
[17:09:05] formatted: 31,461,582
[17:09:05] formatted: -31,461,582
Reply
#29

awesome work.

******, it fixed the problem, I was stuck with it aswell, thanks for giving the fix
Reply
#30

\pawno\include\formatnumber.inc(112) : error 020: invalid symbol name "" ?? What is This
Reply
#31

Quote:
Originally Posted by minhducc
Посмотреть сообщение
\pawno\include\formatnumber.inc(112) : error 020: invalid symbol name "" ?? What is This

Same problem here
Reply
#32

"#define hex:%0;unformat(_:EXTRZ:EXTRX:%1); %0;unformat(_:EXTRZ:EXTRX:%1);"

Problem solved, thank you.
Reply
#33

good include
Reply
#34

Ehh hmm... I'd like to point out that it rounds floats DOWN, instead of up ...
Reply
#35

Slice, I believe this include needs a little love.

- Fix negative numbers.
- Hex: missing from xVariable tag specifications.

Also curious, shouldn't you only search for decimals if its a float? (s_iDecimalPos = strfind( s_szReturn, "." )

EDIT: I went ahead and did my own fixes.

https://gist.github.com/Kar2k/bfb0ea...91b9/revisions
Reply
#36

I meant to ask before, but... Why does this support the following tags: Text3D, Menu, Text, DB, DBResult, and File?
Reply
#37

Quote:
Originally Posted by Crayder
Посмотреть сообщение
I meant to ask before, but... Why does this support the following tags: Text3D, Menu, Text, DB, DBResult, and File?
I think the reason was to make it easy to make a generic "dump this number" function, which supported most common tags one would need to debug.
Reply
#38

invalid download link
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)