Author Topic: Getting the Integer value of a Real Number.  (Read 3479 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Getting the Integer value of a Real Number.
« 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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline GrahamK

  • Atari ST
  • ***
  • Posts: 118
  • Karma: 17
    • View Profile
Re: Getting the Integer value of a Real Number.
« Reply #1 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


Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Getting the Integer value of a Real Number.
« Reply #2 on: January 11, 2007 »
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: