Weird calculation bug?
#1

Hello i am trying to let this make a nice calculation that should be 0.75 because the AHouseData[HouseID][price] = 1

I'm doing this:
pawn Код:
SellPrice = (AHouseData[HouseID][price] * 0.75);
But it always shows me 75000 instead of 0.75

The price of the house is 1 currently so it should show 0.75 shouldnt it?


EDIT: i tried changing the price to something else, it is still showing that it would sell for 75000 anyone an idea why it does this?
Reply
#2

Might work:
pawn Код:
new sellhouseprice = AHouseData[HouseID][price] * 0.75;
SellPrice = sellhouseprice;
Reply
#3

That gives me a tag mismatch because the ( ) brackets are missing. But that wouldn't work the way it should either.
Reply
#4

don't forget to store the value to a Float: variable!
pawn Код:
new Float:sellhouseprice = 0.75 * AHouseData[HouseID][price];
Reply
#5

I used Ikkentim his code it still does this:
Reply
#6

Yeah, I was gonna paste that too @ikkentim.
That's probably your solution. I tested it and it works.
Reply
#7

Quote:
Originally Posted by thimo
Посмотреть сообщение
I used Ikkentim his code it still does this:
Does what? If the rules of math didn't suddenly change then 100000 x 0.75 is 75000.
Reply
#8

Use floatmul(/*houseprice*/,/*the float 0.75*/);

It will work.
Reply
#9

Might come in handy at some point for you.

Note: GetPercentage(price, 75) will get the percentage of 75 for the value you specified, it acts like 0.75. Example: GetPercentage(500, 1) will return 5$ for 0.01%

pawn Код:
stock GetPercent(Float:number, Float:percentage)
{
    new Float:FinalSum;
    FinalSum = (number/100)*percentage;
    return floatround(FinalSum);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)