Newzed

10-22-2006, 09:05 PM

As far as I know, there is no equivalent of the PBasic·' */· '·operator in Spin.· If there is, this is wasted effort.

Here is a method that lets you multiply a number by a decimal:

PUB starslash(n,i,f)····

·· z := n*i + ((n*f)/1000)

"n" is your number, "i" is the integer portion of the multiplier and "f" is the decimal portion of the multiplier without the decimal point.· "z" is a LONG global variable.

If you want to multiply 77 by 3.375 you would call:

··· starslash(77,3,375)·· ' 0.3 percent error

If you want to multiply 77 by 0.375 you would call:

··· starslash(77,0,375)·· '· 3 percent error

The error percentage decreases sharply with larger results for "z".· For example:

··· starslash(475,3 375)

has an error of .007 percent.

Hope this helps someone.

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Sid Weaver

Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)

·

Here is a method that lets you multiply a number by a decimal:

PUB starslash(n,i,f)····

·· z := n*i + ((n*f)/1000)

"n" is your number, "i" is the integer portion of the multiplier and "f" is the decimal portion of the multiplier without the decimal point.· "z" is a LONG global variable.

If you want to multiply 77 by 3.375 you would call:

··· starslash(77,3,375)·· ' 0.3 percent error

If you want to multiply 77 by 0.375 you would call:

··· starslash(77,0,375)·· '· 3 percent error

The error percentage decreases sharply with larger results for "z".· For example:

··· starslash(475,3 375)

has an error of .007 percent.

Hope this helps someone.

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Sid Weaver

Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)

·