Jump to content

Simple division


littlepinkpie
 Share

You are about to reply to a thread that has been inactive for 2332 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have a dynamic list and I need to divide its length with an integer

Currently the list length is 9 and my integer is 2

So Im using

float Result;

MyList=llGetListLength(List);
Result=float(MyList)/float(MyInteger);
llOwnerSay((string)Result);

where MyList=9 and MyInteger=2
but Im getting syntax error at Result=

Link to comment
Share on other sites

When you want the compiler to temporarily treat one kind of variable as another, you use a "typecast". Typecasts are always enclosed in parentheses. So, if you want to temporarily express the integer variable "MyList" as a float, you write "(float)MyList". You wrote float(MyList), which the compiler interprets as a function call to the routine "float" with the argument "MyList". There is no such function, and so you get a syntax error. The correct way to write it is as Rolig showed. "(float)MyList/(float)MyInteger".

Edited by Madelaine McMasters
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2332 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...