From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,16a35419d117fb15,start X-Google-Attributes: gid103376,public From: fluffy_doo@dsuper.net Subject: discriminant Date: 1999/07/11 Message-ID: <3789bfc2.97977684@news.dsuper.net>#1/1 X-Deja-AN: 499785310 Content-Transfer-Encoding: 7bit X-Original-NNTP-Posting-Host: asc9-addr-144.dsuper.net Content-Type: text/plain; charset=us-ascii X-Trace: 11 Jul 1999 12:01:35 -0400, delphi.dsuper.net Organization: via Internet Direct MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-07-11T00:00:00+00:00 List-Id: Hi, I'm having problems with the use of a discriminant for a RECORD that is meant to hold the value for a High Precision Real Number (my own type defined in an ADT). I did *not* get any compilation time errors for any of the things I have done (described below). In my .ADS I have the following private structure: PRIVATE TYPE T_Sign_Temp IS (POSITIVE, NEGATIVE, ABSENT); SUBTYPE T_Sign IS T_Sign_Temp RANGE POSITIVE..NEGATIVE; SUBTYPE T_Digit IS integer RANGE 0..9; TYPE T_Mantissa IS ARRAY (1..MAX_MANT_200) OF T_Digit; SUBTYPE T_Len_Mantissa IS positive RANGE 1..MAX_SIG_FIG_30; SUBTYPE T_Power IS integer RANGE integer'first..integer'last; SUBTYPE T_Positive_Power IS T_Power RANGE 0..integer'last; TYPE T_Kind IS ( INT, REAL, NONE ); TYPE T_Number ( kind : T_Kind := NONE ) IS RECORD Sign : T_Sign := POSITIVE; Mant : T_Mantisse := (OTHERS => 0); Len : T_Lng_Mantisse := 0; CASE kind IS WHEN REAL => Point : natural RANGE 0..MAX_SIG_FIG_30 := 1; Power_R : T_Power := 0; WHEN INT => Power_I : T_Positive_Power := 0; WHEN NONE => NULL; END CASE; END RECORD; When I assign a value to the Power_R for a real numbrer, the "Point" field also changes (mysteriously), and after it has changed I can no longer assign a new value to it. On top of this, the new value that "Point" takes is *outside* my subtype range and no exception is raised ! It tends to take a value a bit over 500, while its top limit is a constant with a value of 30 !?!? I got the value and the moment of the change occuring from the debugger. I have tried a large number of variations for a subprogram whose task is to assign the T_Number fields' values, always with the same result (problem) I have just described. I tried with a function and with a procedure, many versions of each. At first I would assign the fields of my T_Number variable separately, one after the other, as I went along through a decision tree structure. Then I tried putting each field value in a temporary variable and to assign them to my T_Number variable with the "My_Num := (REAL, its_sign, its_mantissa, ...);" method at the end of my subprogram. At first I had a formal parameter of the T_Kind type (INT or REAL) for the discriminant that I was passing to the subprogram. I then wrote two different subprograms, one for each "kind", so I no longer had to pass the discriminant in a parameter. Still the problem persisted. I finally decided I could do without the "Point" field, but I still need to know what I was doing wrong with respect to this discriminant business. If anyone can provide me with some light, I would appreciate it. Thanks in advance. Marc Galipeau -- What I really am is "fluffy", no "_dong", no "_puff", no "_woo", no nothing, just plain fluffy.