Integer Conversion ?

1. Senior Member
Join Date
Dec 1969
Posts
155

## Integer Conversion ?

I have the following number: -122.67890 and I need to convert to the following number: 122<BR><BR>I&#039;ve tried using abs(int(-122.67890)), which SHOULD convert it to 122, however for some reason, the int() function rounds the number to 123. <BR><BR>Does anybody know how to fix this issue?

2. Senior Member
Join Date
Dec 1969
Posts
2,437

.

3. Member
Join Date
Dec 1969
Posts
78

## RE: Integer Conversion ?

try this fix(number)<BR>ex. fix(122.5) should equal 122

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## *OR* Int(Abs(num))

Read the docs on Int. It *always* rounds *down* to the next smaller integer.<BR><BR>The next smaller integer than -122.4431 is, of course, -123.<BR><BR>Fix, on the other hand, rounds toward zero, whether positive or negative. Which is why Lars suggested fix.<BR><BR>But if you take the ABS *first* then INT will do what you want.<BR><BR>It&#039;s all in the wrist, you know.<BR>

5. Senior Member
Join Date
Dec 1969
Posts
155

## RE: *OR* Int(Abs(num))

Haha - Thanks Bill and everyone

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•