* [PATCH] PR fortran/62245 fix INT docs.
@ 2014-08-24 12:38 VandeVondele Joost
2014-08-24 12:44 ` Gerald Pfeifer
0 siblings, 1 reply; 10+ messages in thread
From: VandeVondele Joost @ 2014-08-24 12:38 UTC (permalink / raw)
To: gcc-patches, fortran
A doc change to refine wording for result value of int, avoiding the word range and using magnitude as does the standard. Mentions undefined behavior.
2014-08-24 Joost VandeVondele <vondele@gcc.gnu.org>
PR fortran/62245
* intrinsic.texi (INT): clarify result and undefined behavior.
Index: intrinsic.texi
===================================================================
--- intrinsic.texi (revision 214408)
+++ intrinsic.texi (working copy)
@@ -7371,8 +7371,10 @@ the following rules:
If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
@item (B)
If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
-If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
-the range of @var{A} and whose sign is the same as the sign of @var{A}.
+If @math{|A| \geq 1}, then @code{INT(A)} is the integer whose magnitude is the largest
+integer that does not exceed the magnitude of @var{A} and whose sign is the same as
+the sign of @var{A}. The result is undefined if it can not be represented as an
+@code{INTEGER} of the given @code{KIND}.
@item (C)
If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
@end table
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] PR fortran/62245 fix INT docs.
2014-08-24 12:38 [PATCH] PR fortran/62245 fix INT docs VandeVondele Joost
@ 2014-08-24 12:44 ` Gerald Pfeifer
2014-08-24 12:47 ` VandeVondele Joost
0 siblings, 1 reply; 10+ messages in thread
From: Gerald Pfeifer @ 2014-08-24 12:44 UTC (permalink / raw)
To: VandeVondele Joost; +Cc: gcc-patches, fortran
On Sun, 24 Aug 2014, VandeVondele Joost wrote:
> A doc change to refine wording for result value of int, avoiding the
> word range and using magnitude as does the standard. Mentions undefined
> behavior.
>
> 2014-08-24 Joost VandeVondele <vondele@gcc.gnu.org>
>
> PR fortran/62245
> * intrinsic.texi (INT): clarify result and undefined behavior.
Looks good to me, though better wait for a Fortran maintainer to be
sure.
One small ask: these lines are too long (already before your patch);
can you please reformat those lines your patch touches to <80 columns?
Thanks,
gerald
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] PR fortran/62245 fix INT docs.
2014-08-24 12:44 ` Gerald Pfeifer
@ 2014-08-24 12:47 ` VandeVondele Joost
2014-08-24 15:49 ` Steve Kargl
0 siblings, 1 reply; 10+ messages in thread
From: VandeVondele Joost @ 2014-08-24 12:47 UTC (permalink / raw)
To: Gerald Pfeifer; +Cc: gcc-patches, fortran
> One small ask: these lines are too long (already before your patch);
> can you please reformat those lines your patch touches to <80 columns?
sure:
Index: intrinsic.texi
===================================================================
--- intrinsic.texi (revision 214408)
+++ intrinsic.texi (working copy)
@@ -7370,9 +7370,12 @@ the following rules:
@item (A)
If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
@item (B)
-If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
-If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
-the range of @var{A} and whose sign is the same as the sign of @var{A}.
+If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)}
+equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer
+whose magnitude is the largest integer that does not exceed the magnitude
+of @var{A} and whose sign is the same as the sign of @var{A}. The result
+is undefined if it can not be represented as an @code{INTEGER} of the
+given @code{KIND}.
@item (C)
If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
@end table
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] PR fortran/62245 fix INT docs.
2014-08-24 12:47 ` VandeVondele Joost
@ 2014-08-24 15:49 ` Steve Kargl
2014-08-24 15:58 ` VandeVondele Joost
0 siblings, 1 reply; 10+ messages in thread
From: Steve Kargl @ 2014-08-24 15:49 UTC (permalink / raw)
To: VandeVondele Joost; +Cc: Gerald Pfeifer, gcc-patches, fortran
On Sun, Aug 24, 2014 at 12:47:18PM +0000, VandeVondele Joost wrote:
> > One small ask: these lines are too long (already before your patch);
> > can you please reformat those lines your patch touches to <80 columns?
>
> sure:
>
> +of @var{A} and whose sign is the same as the sign of @var{A}. The result
> +is undefined if it can not be represented as an @code{INTEGER} of the
> +given @code{KIND}.
The last sentence above is not needed. There is a general
prohibition in 13.7.1 against calling INT(A) with |A| > HUGE(1_4).
--
Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] PR fortran/62245 fix INT docs.
2014-08-24 15:49 ` Steve Kargl
@ 2014-08-24 15:58 ` VandeVondele Joost
2014-08-24 16:56 ` Steve Kargl
0 siblings, 1 reply; 10+ messages in thread
From: VandeVondele Joost @ 2014-08-24 15:58 UTC (permalink / raw)
To: Steve Kargl; +Cc: Gerald Pfeifer, gcc-patches, fortran
>> +of @var{A} and whose sign is the same as the sign of @var{A}. The result
>> +is undefined if it can not be represented as an @code{INTEGER} of the
>> +given @code{KIND}.
>
>The last sentence above is not needed.
but helpful for gfortran users ?
> There is a general
> prohibition in 13.7.1 against calling INT(A) with |A| > HUGE(1_4).
maybe you could prepare a patch to add something like that to the section on intrinsics ?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] PR fortran/62245 fix INT docs.
2014-08-24 15:58 ` VandeVondele Joost
@ 2014-08-24 16:56 ` Steve Kargl
2014-08-24 17:12 ` VandeVondele Joost
2014-09-05 11:16 ` VandeVondele Joost
0 siblings, 2 replies; 10+ messages in thread
From: Steve Kargl @ 2014-08-24 16:56 UTC (permalink / raw)
To: VandeVondele Joost; +Cc: Gerald Pfeifer, gcc-patches, fortran
On Sun, Aug 24, 2014 at 03:58:42PM +0000, VandeVondele Joost wrote:
> >> +of @var{A} and whose sign is the same as the sign of @var{A}. The result
> >> +is undefined if it can not be represented as an @code{INTEGER} of the
> >> +given @code{KIND}.
> >
> >The last sentence above is not needed.
>
> but helpful for gfortran users ?
>
The problem is that a similar sentence would then need to be
added to other intrinsic subroutines/functions where an actual
argument might produce a result that is out-of-range of the
representable entity. Note, that it isn't limited to just
the conversion functions. Consider IABS() and the asymetric
range of the INTEGERi type.
integer i
i = - huge(i) - 1
print *, iabs(i)
end
> > There is a general
> > prohibition in 13.7.1 against calling INT(A) with |A| > HUGE(1_4).
>
> maybe you could prepare a patch to add something like that to the
> section on intrinsics?
Sure, I'll come up with a statement to be added to Sec. 8.1 of
the gfortran manual.
--
Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] PR fortran/62245 fix INT docs.
2014-08-24 16:56 ` Steve Kargl
@ 2014-08-24 17:12 ` VandeVondele Joost
2014-09-05 11:16 ` VandeVondele Joost
1 sibling, 0 replies; 10+ messages in thread
From: VandeVondele Joost @ 2014-08-24 17:12 UTC (permalink / raw)
To: Steve Kargl; +Cc: Gerald Pfeifer, gcc-patches, fortran
>> but helpful for gfortran users ?
>The problem is that a similar sentence would then need to be
>added to other intrinsic subroutines/functions where an actual
>argument might produce a result that is out-of-range of the
>representable entity.
So, I could remove the sentence if there is consensus.
>> maybe you could prepare a patch to add something like that to the
>> section on intrinsics?
>
>Sure, I'll come up with a statement to be added to Sec. 8.1 of
>the gfortran manual.
actually, it is more complicated, since gfortran does support things such as NaN, and Inf, depending on the hardware and the compilation options.
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] PR fortran/62245 fix INT docs.
2014-08-24 16:56 ` Steve Kargl
2014-08-24 17:12 ` VandeVondele Joost
@ 2014-09-05 11:16 ` VandeVondele Joost
2014-09-05 13:34 ` Steve Kargl
1 sibling, 1 reply; 10+ messages in thread
From: VandeVondele Joost @ 2014-09-05 11:16 UTC (permalink / raw)
To: Steve Kargl; +Cc: Gerald Pfeifer, gcc-patches, fortran
> >The last sentence above is not needed.
So, revised patch without the last sentence.
2014-09-05 Joost VandeVondele <vondele@gcc.gnu.org>
PR fortran/62245
* intrinsic.texi (INT): clarify result.
Index: fortran/intrinsic.texi
===================================================================
--- fortran/intrinsic.texi (revision 214949)
+++ fortran/intrinsic.texi (working copy)
@@ -7370,9 +7370,10 @@ the following rules:
@item (A)
If @var{A} is of type @code{INTEGER}, @code{INT(A) = A}
@item (B)
-If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)} equals @code{0}.
-If @math{|A| \geq 1}, then @code{INT(A)} equals the largest integer that does not exceed
-the range of @var{A} and whose sign is the same as the sign of @var{A}.
+If @var{A} is of type @code{REAL} and @math{|A| < 1}, @code{INT(A)}
+equals @code{0}. If @math{|A| \geq 1}, then @code{INT(A)} is the integer
+whose magnitude is the largest integer that does not exceed the magnitude
+of @var{A} and whose sign is the same as the sign of @var{A}.
@item (C)
If @var{A} is of type @code{COMPLEX}, rule B is applied to the real part of @var{A}.
@end table
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-09-05 13:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-24 12:38 [PATCH] PR fortran/62245 fix INT docs VandeVondele Joost
2014-08-24 12:44 ` Gerald Pfeifer
2014-08-24 12:47 ` VandeVondele Joost
2014-08-24 15:49 ` Steve Kargl
2014-08-24 15:58 ` VandeVondele Joost
2014-08-24 16:56 ` Steve Kargl
2014-08-24 17:12 ` VandeVondele Joost
2014-09-05 11:16 ` VandeVondele Joost
2014-09-05 13:34 ` Steve Kargl
2014-09-05 13:40 ` VandeVondele Joost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).