Weird calculation bug? -
thimo - 23.12.2014
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?
Re: Weird calculation bug? -
LivingLikeYouDo - 23.12.2014
Might work:
pawn Код:
new sellhouseprice = AHouseData[HouseID][price] * 0.75;
SellPrice = sellhouseprice;
Re: Weird calculation bug? -
thimo - 23.12.2014
That gives me a tag mismatch because the ( ) brackets are missing. But that wouldn't work the way it should either.
Re: Weird calculation bug? -
ikkentim - 23.12.2014
don't forget to store the value to a Float: variable!
pawn Код:
new Float:sellhouseprice = 0.75 * AHouseData[HouseID][price];
Re: Weird calculation bug? -
thimo - 23.12.2014
I used Ikkentim his code it still does this:
Re: Weird calculation bug? -
LivingLikeYouDo - 23.12.2014
Yeah, I was gonna paste that too @ikkentim.
That's probably your solution. I tested it and it works.
Re: Weird calculation bug? -
Vince - 23.12.2014
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.
AW: Weird calculation bug? -
Flori - 23.12.2014
Use floatmul(/*houseprice*/,/*the float 0.75*/);
It will work.
Re: Weird calculation bug? -
zT KiNgKoNg - 23.12.2014
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);
}