[PR88579, patch] Calculating power of powers of two
Thomas Koenig
tkoenig@netcologne.de
Sat Jan 19 15:45:00 GMT 2019
Hi Harald,
> now that my copyright assignment is on file, here's my first attempt
> at a non-trivial patch.
Excellent :-)
> I have slightly rearranged Thomas' code, removed some, and added
> generalizations for (2**e)**n and (-2**e)**n. It works with the
> testcase below.
That looks good.
> I'd like some feedback how to properly handle the case when
> (-2**e) = -HUGE()-1, i.e. the number that falls outside the
> symmetric range. Should one skip that one? Does anyone have
> a template how to detect that case easily? Regtesting otherwise
> would fail for the last test (which most likely should be removed
> later).
I think it is fine to fall back on the library version (which still
exists) for that one.
The best way to check this is probably by getting the bit size
of the expression by using something like
ikind = gfc_validate_kind (BT_INTEGER, expr->ts.kind, false);
bit_size = gfc_integer_kinds[ikind].bit_size;
and take it from there.
Regards
Thomas
More information about the Fortran
mailing list