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
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
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__
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
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__
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