float problems
#1

Well I'm doing a system with a float well it wont work anyways

pawn Код:
PlayerInfo[playerid][pFloatt] += 4200 / KIP[eBuyPrice]; // the buy price is 500.000$
va_print("%f float", PlayerInfo[playerid][pFloatt]);
[00:33:26] 0.000000 float
Soo yeah?
Reply
#2

What's the initial value of PlayerInfo[playerid][pFloatt]?
Reply
#3

Quote:
Originally Posted by GRiMMREAPER
Посмотреть сообщение
What's the initial value of PlayerInfo[playerid][pFloatt]?
In my MySQL database its "None" if that's what u mean or "0" it types out "0" when I create it, I mean the column
Reply
#4

Make sure that PlayerInfo[playerid][pFloatt]* and KIP[eBuyPrice]* are both floats. Just to be safe, you could convert 4200 to float, therefore making it 4200.0 or float(4200).

pawn Код:
new Float:foo;
    foo += 4200.0/500000.0;
    printf("%.5f", foo);
This happens because integer division truncates (4200/500000 < 0, so it truncates — rounds down — to 0), so you need to make sure atleast one of the parameters is of type float.

* In your enums, set pFloatt to Float: pFloatt and eBuyPrice to Float:eBuyPrice.
Reply
#5

Quote:
Originally Posted by GRiMMREAPER
Посмотреть сообщение
Make sure that PlayerInfo[playerid][pFloatt] and KIP[eBuyPrice] are both floats. Just to be safe, you could convert 4200 to float, therefore making it 4200.0 or float(4200).

pawn Код:
new Float:foo;
    foo = 4200.0/500000.0;
    printf("%.5f", foo);
This happens because integer division truncates (4200/500000 < 0, so it truncates — rounds down — to 0), so you need to make sure atleast one of the parameters is of type float.
hmm "eBuyPrice" is an int lemme fix that and try
Reply
#6

Quote:
Originally Posted by IdonTmiss
Посмотреть сообщение
hmm "eBuyPrice" is an int lemme fix that and try
That should be the problem, as the rest of the code has no errors. I appended some information to my initial reply.
Reply
#7

Quote:
Originally Posted by GRiMMREAPER
Посмотреть сообщение
That should be the problem, as the rest of the code has no errors. I appended some information to my initial reply.
It works ! Arigato Gozaimasu
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)