Re: 'Base



Matthew Heaney wrote:
T'Base refers to the "base range" of the type, which defines the range
in which intermediate calculations are performed.

The standard states that the range of T'Base:

(1) includes the value 0
(2) is symmetric about zero, with possibly an extra negative value
(3) includes all of the values in the subtype T

So for example, if T is:

  type T is 1 .. 42;

then T'Base is

  type T'Base is -42 .. 42;

[snip]
I might have some of the details wrong, but that's the general idea.

Sorry Matt - you must be ill or something as you're a wee bit "off base" with your answer to this one!


Try this test prog to see what actually happens:

with Ada.Text_IO; use Ada.Text_IO;

procedure Test_Base is
   type T is range 1 .. 42;
begin
   Put_Line (T'Base'Image (T'Base'First));
   Put_Line (T'Base'Image (T'Base'Last));
end Test_Base;

It isn't -42 .. 42 but the 'First .. 'Last or the underlying integer representation. In this case (with ObjectAda) -2147483648 to 2147483647.

Cheers

-- Martin
.



Relevant Pages

  • Re: Calculations in SQL
    ... it gets a fraction and sees it as zero. ... calculations you're doing), it's getting rounded down to 0. ... Dim curOneFif As Currency ... Dim intSumPop As Long ...
    (microsoft.public.access.adp.sqlserver)
  • Re: GFloat Rounding issue in DEC Basic V1.2-000
    ... I have manually done the calculations and am versed in the ... I just knew that the recriminations about using floating point would be fired out rather quickly, and John and Tom didn't disappoint me. ... Richard has the right concept, but I think his fingers got a bit ahead of him. ... if ABS< (your spec for zero) then it's zero. ...
    (comp.os.vms)
  • Re: Numerical systems
    ... Have there ever been a numerical system where zero is undefined? ... Is it possible to construct a numerical system that can perform all ... what does it mean to perform all calculations ... with finite decimal representation. ...
    (sci.math)
  • Re: Making Negative Results Default to Zero
    ... how it would affect your other constraints. ... > calculations in other sheets. ... > results less than zero must be set to zero for calculations that ... > formula calculation yields a result less than zero, the cell is ...
    (microsoft.public.excel.misc)
  • Re: SR inconsistent?
    ... I've don't have time right now to go through all of your calculations, ... V'_y is not zero at t' = 0 because V_y ... "4/3 Problem Resolution" ... "Action-reaction Paradox Resolution" ...
    (sci.physics.relativity)