From: Leo
Subject: fortran to common lisp: aint
Date: 
Message-ID: <m0ocsix339.fsf@cam.ac.uk>
Hi,

In the following fortran code:

    AINT(Y*SIXTEN)/SIXTEN

where SIXTEN is defined as 16d0, what is AINT in common lisp?

At the moment I use `TRUNCATE'

  (/ (truncate (* y sixten)) sixten)

Is this correct? Thank you. -- Leo

-- 
Emacs uptime: 2 days, 16 hours, 11 minutes, 36 seconds

From: Tamas K Papp
Subject: Re: fortran to common lisp: aint
Date: 
Message-ID: <7a4objF1t8kenU1@mid.individual.net>
On Sat, 20 Jun 2009 17:49:30 +0100, Leo wrote:

> Hi,
> 
> In the following fortran code:
> 
>     AINT(Y*SIXTEN)/SIXTEN
> 
> where SIXTEN is defined as 16d0, what is AINT in common lisp?
> 
> At the moment I use `TRUNCATE'
> 
>   (/ (truncate (* y sixten)) sixten)
> 
> Is this correct? Thank you. -- Leo

You can answer your question by looking at the specs of the two
functions.  I don't know what AINT does, but note that truncate is
towards 0, not negative infinity (like floor).

Also note that truncate (and similar functions) take a second
argument, so

(/ (truncate y 1/16) 16)

could work equally well for you.

Tamas
From: Pascal J. Bourguignon
Subject: Re: fortran to common lisp: aint
Date: 
Message-ID: <87ws76emfs.fsf@galatea.local>
Leo <·······@gmail.com> writes:

> Hi,
>
> In the following fortran code:
>
>     AINT(Y*SIXTEN)/SIXTEN
>
> where SIXTEN is defined as 16d0, what is AINT in common lisp?
>
> At the moment I use `TRUNCATE'
>
>   (/ (truncate (* y sixten)) sixten)
>
> Is this correct? Thank you. -- Leo

You should tell us what AINT is in Fortran.
Since its name starts by a A, isn't it a function that returns a float?


-- 
__Pascal Bourguignon__
From: Leo
Subject: Re: fortran to common lisp: aint
Date: 
Message-ID: <m0k536wryk.fsf@cam.ac.uk>
On 2009-06-20 20:26 +0100, Pascal J. Bourguignon wrote:
> Leo <·······@gmail.com> writes:
>
>> Hi,
>>
>> In the following fortran code:
>>
>>     AINT(Y*SIXTEN)/SIXTEN
>>
>> where SIXTEN is defined as 16d0, what is AINT in common lisp?
>>
>> At the moment I use `TRUNCATE'
>>
>>   (/ (truncate (* y sixten)) sixten)
>>
>> Is this correct? Thank you. -- Leo
>
> You should tell us what AINT is in Fortran.
> Since its name starts by a A, isn't it a function that returns a float?

This is the first time I look at fortran. I guess TRUNCATE based on the
doc here.

http://www.sunsite.ualberta.ca/Documentation/Gnu/gcc-2.95.2/html_node/g77_81.html

But I am not sure if TRUNCATE is the equivalent.

-- 
Emacs uptime: 2 days, 20 hours, 14 minutes, 17 seconds
From: Pascal J. Bourguignon
Subject: Re: fortran to common lisp: aint
Date: 
Message-ID: <878wjmehg6.fsf@galatea.local>
Leo <·······@gmail.com> writes:

> On 2009-06-20 20:26 +0100, Pascal J. Bourguignon wrote:
>> Leo <·······@gmail.com> writes:
>>
>>> Hi,
>>>
>>> In the following fortran code:
>>>
>>>     AINT(Y*SIXTEN)/SIXTEN
>>>
>>> where SIXTEN is defined as 16d0, what is AINT in common lisp?
>>>
>>> At the moment I use `TRUNCATE'
>>>
>>>   (/ (truncate (* y sixten)) sixten)
>>>
>>> Is this correct? Thank you. -- Leo
>>
>> You should tell us what AINT is in Fortran.
>> Since its name starts by a A, isn't it a function that returns a float?
>
> This is the first time I look at fortran. I guess TRUNCATE based on the
> doc here.
>
> http://www.sunsite.ualberta.ca/Documentation/Gnu/gcc-2.95.2/html_node/g77_81.html
>
> But I am not sure if TRUNCATE is the equivalent.

"truncation toward zero" is present in the specifications of both AINT
and TRUNCATE, but AINT returns a real while TRUNCATE returns an
integer.  You want FTRUNCATE.


-- 
__Pascal Bourguignon__
From: Leo
Subject: Re: fortran to common lisp: aint
Date: 
Message-ID: <m0d48ywkya.fsf@cam.ac.uk>
On 2009-06-20 22:14 +0100, Pascal J. Bourguignon wrote:
> "truncation toward zero" is present in the specifications of both AINT
> and TRUNCATE, but AINT returns a real while TRUNCATE returns an
> integer.  You want FTRUNCATE.

Thanks ;)

-- 
Emacs uptime: 2 days, 22 hours, 47 minutes, 4 seconds