comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Constraint error overflow
Date: Tue, 27 Apr 2021 08:44:24 -0700 (PDT)	[thread overview]
Message-ID: <48671e5c-8e9d-41c1-9ebc-2b4de6e0ed29n@googlegroups.com> (raw)
In-Reply-To: <be95bd99-dc1e-44ec-ac26-a2bacc1e8f86n@googlegroups.com>

On Tuesday, April 27, 2021 at 9:32:20 AM UTC-6, haujek wrote:
> So the compiler is restricted to 32 bit integer value. I had hoped for 64 bit to get 18 digits. 

Depends on the compiler.
You can always model your domain more explicitly:
Bit_Size : Constant := 64;
Bit_First : Constant := 0;
Bit_Last : Constant := 2**Big_Bit_Size - 1;
Type Big_Integer_Test is range Bit_First..Bit_Last with Size => Bit_Size;

Function Factorial(Input:Big_Integer_Test) return Big_Integer_Test is
(case Input is
  when 0 => 1,
  when 1 | 2 => Input,
  when others => Input * Factorial(Big_Integer_Test'Pred(Input))
);

  parent reply	other threads:[~2021-04-27 15:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 14:04 Constraint error overflow Richard Iswara
2021-04-27 15:00 ` Dmitry A. Kazakov
2021-04-27 15:32   ` Richard Iswara
2021-04-27 15:38     ` Mark Lorenzen
2021-04-27 15:44     ` Shark8 [this message]
2021-04-27 15:52     ` Jeffrey R. Carter
2021-04-27 15:59     ` Dmitry A. Kazakov
2021-04-28  7:03       ` Richard Iswara
2021-04-27 16:31     ` Simon Wright
replies disabled

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