Tag mismatch on a float?
#1

I'm getting these really screwy errors and nothing I can think of has been able to help out:
Код:
C:\Users\joeytucker\Desktop\SAMP037svr\gamemodes\IRP.pwn(23135) : warning 213: tag mismatch
C:\Users\joeytucker\Desktop\SAMP037svr\gamemodes\IRP.pwn(23140) : warning 213: tag mismatch
C:\Users\joeytucker\Desktop\SAMP037svr\gamemodes\IRP.pwn(23145) : warning 213: tag mismatch
C:\Users\joeytucker\Desktop\SAMP037svr\gamemodes\IRP.pwn(23145) : warning 213: tag mismatch
C:\Users\joeytucker\Desktop\SAMP037svr\gamemodes\IRP.pwn(23150) : warning 213: tag mismatch
I understand what this means, I just don't understand why I get them.

pawn Код:
format(string, sizeof(string), "SELECT Sum(`Crack`), Sum(`Pot`), Sum(`Materials`) FROM `Users`");
    query = sql_query(SQL:1, string);
    sql_store_result(query);
    new crackamount = sql_get_field_int(query, 0);
    new potamount = sql_get_field_int(query, 1);
    new matamount = sql_get_field_int(query, 2);
    new Float:crackgpricetemp, Float:potgpricetemp,
        Float:matpricetemp, Float:DriversLicenseCosttemp;

    if(TaxValue >= 25000) {
        DriversLicenseCosttemp = (0.5/TaxValue^2) * 10^13;
    }
    else DriversLicenseCosttemp = (8000);

    if(potamount >= 100) {
        potgpricetemp = (0.5/potamount^2) * 10^7; //price per gram
    }
    else potgpricetemp = (500);

    if(matamount >= 17677) {
        matpricetemp = (0.5/matamount^2) * 2.5 * 10^12;
    }
    else matpricetemp = (4000);

    if(crackamount >= 100) {
        crackgpricetemp = (0.5/crackamount^2) * 10^8; //price per gram
    }
    else crackgpricetemp = (5000);
    sql_free_result(query);
Each equation (matpricetemp = ..., etc) is the 'tag mismatch' line.

matpricetemp, potgpricetemp, crackgpricetemp and DriversLicenseCosttemp are all floats, so why do I have tag mismatches? crackamount, potamount and matamount are all clearly untagged (integers) and TaxValue is the same.

I have tried the following:
  • Adding float() tags around the equations (so matpricetemp = float((0.5/matamount^2) * 2.5 * 10^ et cetera)
  • Using integers instead of floats for crackgpricetemp et cetera, and using crackgpricetemp = floatround((0.5/crackamount^2) * 10^;
  • Printing the values to see what's happening with the following:
    pawn Код:
    crackgprice = floatround(crackgpricetemp);
        DriversLicenseCost = floatround(DriversLicenseCosttemp);
        matprice = floatround(matpricetemp);
        potgprice = floatround(potgpricetemp);
       
        printf("crackgprice = %d / %f / %d", crackgprice, crackgpricetemp, crackamount);
        printf("potgprice = %d / %f / %d", potgprice, potgpricetemp, potamount);
        printf("DriversLicenseCost = %d / %f / %d", DriversLicenseCost, DriversLicenseCosttemp, TaxValue);
        printf("matprice = %d / %f / %d", matprice, matpricetemp, matamount);
I have also tried changing crackgprice = floatround(crackgpricetemp); to crackgprice = _:crackgpricetemp; and it still doesn't work.

What I get from the printfs:
Код:
[11:41:05] crackgprice = 1319677019 / 1414933888.000000 / 101
[11:41:05] potgprice = 1318862193 / 1310636160.000000 / 250
[11:41:05] DriversLicenseCost = 1174011904 / 8000.000000 / 423
[11:41:05] matprice = 1319196057 / 1353370752.000000 / 100000
What's puzzling me, is I do the following:
pawn Код:
DriversLicenseCost = floatround(DriversLicenseCosttemp);
and:
pawn Код:
DriversLicenseCost = _:DriversLicenseCosttemp;
and I get...
Код:
DriversLicenseCost = 1174011904
DriversLicenseCosttemp = 8000.000000
TaxValue = 423
So what gives? I've searched over the forums and every post I've come across has said you can use floatround() and _:var to convert a float to an integer:

Quote:
Originally Posted by Jeffry
new YourInteger = floatround(/*YourFloat*/, floatround_round);
Quote:
new Float:fMyFloat = 1.3;
new nSomeInt = _:fMyFloat;

//nSomeInt is now 1.
I'm completely stumped and out of answers.

Another error is the following:
Код:
[11:41:05] crackgprice = 1319677019 / 1414933888.000000 / 101
Even the float is calculated wrong:
Код:
crackgpricetemp = (0.5/crackamount^2) * 10^8;
I'm 100% sure that (0.5/101^2) * 10^8 is not 1414933888, so what is the problem?
Reply
#2

You can't use ^ operator in Pawn for floats, AFAIK it's the binary XOR operator and can be only used on ints.
If you need to square something or raise to a power use floatpower or just multiply by the same number.
Reply
#3

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
You can't use ^ operator in Pawn for floats, AFAIK it's the binary XOR operator and can be only used on ints.
If you need to square something or raise to a power use floatpower or just multiply by the same number.
Will try that, I wouldn't think that'd be a problem since I'm not raising any floats to a power (matamount, potamount, crackamount, TaxValue and 10 are all integers).

Thanks, will test it out now.
Reply
#4

The problem is it tries to divide a float by a number. And it expects a floating point number. It's defined that way in float.inc, it has to be a float number.
No prob
Reply
#5

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
The problem is it tries to divide a float number by a number. And it expects a floating point number. It's defined that way in float.inc, it has to be a float number.
No prob
Yup, all tag mismatches are gone, time to test it out! Thanks again!

Код:
[12:23:07] crackgprice = 4901 / 4901.479980 / 101
[12:23:07] potgprice = 80 / 80.000000 / 250
[12:23:07] DriversLicenseCost = 8000 / 8000.000000 / 423
[12:23:07] matprice = 125 / 124.999992 / 100000
You're a genius!
Reply
#6

For future reference, performing the tag remover (_:) on a float gives you a weird number because floats and integers are calculated differently in 4byte variables.
They're basically 2 different kinds of numbers, just like hexadecimal and binary.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)