comp.lang.ada
 help / color / mirror / Atom feed
* Gnat bug or mistaken program?
@ 2021-07-20 12:02 Richard Iswara
  2021-07-20 14:09 ` Niklas Holsti
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Iswara @ 2021-07-20 12:02 UTC (permalink / raw)


I get this error on my program from the menu build => check semantic
exponent must be of type Natural, found type "Standard.Float".

Should not 10 ** (log10 a + log10 b) = a*b?

This is my compiler build:

GNAT Studio Community 2020 (20200427) hosted on x86_64-pc-mingw32
GNAT Community 2020 (20200429-93) targetting x86_64-pc-mingw32
SPARK Community 2020 (20200429)

Here is the relevant part of program:

with Ada.Numerics.Elementary_Functions;  
use Ada.Numerics;

Counter : Integer := 1;
Logs : Float := 0.0;
Multiples : Float;

inside some loop:

Logs := Elementary_Functions.Log (Float(Counter), 10.0) + Logs;
Multiples := 10.0 ** Logs;  => this is where it fails

I checked the Ada.Numerics.Generic_Elementary_Functions specifications
(since Ada.Numerics.Elementary_Functions is just an instance of the generics)
and it said:

   function "**" (Left, Right : Float_Type'Base) return Float_Type'Base with
     Pre  => (if Left = 0.0 then Right > 0.0) and Left >= 0.0,
     Post => "**"'Result >= 0.0
       and then (if Right = 0.0 then "**"'Result = 1.0)
       and then (if Right = 1.0 then "**"'Result = Left)
       and then (if Left  = 1.0 then "**"'Result = 1.0)
       and then (if Left  = 0.0 then "**"'Result = 0.0);

So the question is this a Gnat bug, wrong function used, faulty logic on me or
I am declaring it wrong?

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-07-29  0:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 12:02 Gnat bug or mistaken program? Richard Iswara
2021-07-20 14:09 ` Niklas Holsti
2021-07-21  2:23   ` Richard Iswara
2021-07-21  8:29     ` Jeffrey R. Carter
2021-07-21 16:56       ` Shark8
2021-07-22  2:14         ` Richard Iswara
2021-07-27 16:00       ` Niklas Holsti
2021-07-28  5:21         ` J-P. Rosen
2021-07-29  0:46         ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox