Dark Bit Factory & Gravity

ARCHIVE => Archive => Cobra => Topic started by: Clyde on January 11, 2007

Title: Getting the Integer value of a Real Number.
Post by: Clyde on January 11, 2007
Hiya,

Is there a way to convert a real number to the nearest Integer?

In Blitz it would be:
Code: [Select]
Value=Int(Abs(vbtz(a)))

Cheers and many thanks,
Clyde.
Title: Re: Getting the Integer value of a Real Number.
Post by: GrahamK on January 11, 2007
if "value" is an integer it will autoconvert.

if value is a real, there are a few ways.
1. value = round(abs(a),0)   // round to 0 decimal places, you can round to any number of places
2. value = floor(a) // always round down
3. value = ceil(a) // always round up

Title: Re: Getting the Integer value of a Real Number.
Post by: Clyde on January 11, 2007
Smart stuff and thanks dude.

Cheers and all the best,
Clyde.