• Welcome to Dark Bit Factory & Gravity.
 

Getting the Integer value of a Real Number.

Started by Clyde, January 11, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Clyde

Hiya,

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

In Blitz it would be:

Value=Int(Abs(vbtz(a)))


Cheers and many thanks,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

GrahamK

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


Clyde

Smart stuff and thanks dude.

Cheers and all the best,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won: