Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP - Change number to an integer

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
318 Views, 6 Replies

LISP - Change number to an integer

In LISP programmation, I do a calculation and the result for example is : 7.54 I want to transforme this number to an integer number : 7

How can I round it?

thanks

Georges.
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

(atoi 7.54)
Message 3 of 7
Anonymous
in reply to: Anonymous

OOPS !

I meant (fix 7.54)
Message 4 of 7
Anonymous
in reply to: Anonymous

(fix 7.54) will return 7
(fix (+ 7.54 0.5)) will return 8

Use the second option for rounding to the nearest integer.
___

"getibouf" wrote in message
news:f089155.-1@WebX.maYIadrTaRb...
> In LISP programmation, I do a calculation and the result for example is :
7.54 I want to transforme this number to an integer number : 7
> How can I round it?
Message 5 of 7
Anonymous
in reply to: Anonymous

If you need to return a real

(float (fix 7.54)) will return 7.0
(float (fix (+ 7.54 0.5))) will return 8.0

-Jason


"Paul Turvill" wrote in message
news:0C732410079765F056A29D0BC2C3C855@in.WebX.maYIadrTaRb...
> (fix 7.54) will return 7
> (fix (+ 7.54 0.5)) will return 8
>
> Use the second option for rounding to the nearest integer.
> ___
>
> "getibouf" wrote in message
> news:f089155.-1@WebX.maYIadrTaRb...
> > In LISP programmation, I do a calculation and the result for example is
:
> 7.54 I want to transforme this number to an integer number : 7
> > How can I round it?
>
>
>
Message 6 of 7
Anonymous
in reply to: Anonymous

See Subject line.

"Jason Piercey" wrote in message
news:1C82D3E89D17CB839A9011A19F3C363A@in.WebX.maYIadrTaRb...
> If you need to return a real
Message 7 of 7
Anonymous
in reply to: Anonymous

Just providing some extra information, Paul.

-Jason


"Paul Turvill" wrote in message
news:A6151A63487719B9951CF40310EF3F52@in.WebX.maYIadrTaRb...
> See Subject line.
>
> "Jason Piercey" wrote in message
> news:1C82D3E89D17CB839A9011A19F3C363A@in.WebX.maYIadrTaRb...
> > If you need to return a real
>
>
>

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost