Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Type Mismatch?

Alexis Starbrook
CEO - Alexis Digital
Join date: 7 Dec 2006
Posts: 135
02-09-2007 19:48
integer pay_amount;
integer com_amount;

pay_amount = 100;
com_amount = pay_amount * 0.20;


Can anyone tell me why that should come up with a 'type mismatch' error??
_____________________
Damet Neumann
Registered User
Join date: 21 Apr 2006
Posts: 140
only thing i can think of
02-09-2007 20:22
i believe in the wiki somwhere i saw a integer multiplied by a float (which is what .20 would be i think) returns a float instead of an integer.

its only aguess on my part im not that good with scripting, or building or really anything for that matter
Adam Ramona
Registered User
Join date: 5 Jan 2005
Posts: 56
02-09-2007 23:49
I think Damet is right (see Damet, you *are* good at something :). Why not just make pay_amount and com_amount floats instead of integers? That compiles error-free on my editor.
Limpen Lumpen
Registered User
Join date: 5 Jun 2006
Posts: 6
02-10-2007 00:33
From: Alexis Starbrook
integer pay_amount;
integer com_amount;

pay_amount = 100;
com_amount = pay_amount * 0.20;


Can anyone tell me why that should come up with a 'type mismatch' error??


com_amount = (integer)((float)pay_amount * 0.20);

That will give you an integer answer - the 1st reply was correct you cannot mix an integer and a float.
Alexis Starbrook
CEO - Alexis Digital
Join date: 7 Dec 2006
Posts: 135
02-10-2007 00:44
This worked.

integer pay_amount;
integer com_amount;

float pamt=(float)pay_amount;
float camt=pamt * 0.20;
com_amount = (integer)camt;

I know the above poster did it all on one line, but I have to do it the hard way :D
Thanks for the help...
Muchly Appreciated!

Cheers
_____________________