comp.lang.ada
 help / color / mirror / Atom feed
* How to model unknown values in a vector?
@ 2003-05-31 13:43 Harald Schmidt
  2003-05-31 22:47 ` FranciKait
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Harald Schmidt @ 2003-05-31 13:43 UTC (permalink / raw)


Hi,

Does anyone know how to model values in a vector, which are unknown. I can't
use the zero value because this is a valid value. Minus infinity could be an
option, but I am searching for a better method to handle unknown values.

Harald




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

* Re: How to model unknown values in a vector?
  2003-05-31 13:43 How to model unknown values in a vector? Harald Schmidt
@ 2003-05-31 22:47 ` FranciKait
  2003-06-01  3:17 ` Jeffrey Carter
  2003-06-04  1:04 ` Nick Roberts
  2 siblings, 0 replies; 5+ messages in thread
From: FranciKait @ 2003-05-31 22:47 UTC (permalink / raw)


>Does anyone know how to model values in a vector, which are unknown. I can't
>use the zero value because this is a valid value. Minus infinity could be an
>option, but I am searching for a better method to handle unknown values.
>
Hello Harald,
As a prototypical 'Ancient Newbie', I'd take a wild guess at using 'Nul',
'Nil', or whatever.  Haven't tried it myself, but woulda have to think the
compiler simply needs a place holder it won't choke on.  Good luck.

Fran Renard
Vacaville, CA



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

* Re: How to model unknown values in a vector?
  2003-05-31 13:43 How to model unknown values in a vector? Harald Schmidt
  2003-05-31 22:47 ` FranciKait
@ 2003-06-01  3:17 ` Jeffrey Carter
  2003-06-04  1:04 ` Nick Roberts
  2 siblings, 0 replies; 5+ messages in thread
From: Jeffrey Carter @ 2003-06-01  3:17 UTC (permalink / raw)


Harald Schmidt wrote:
 >
 > Does anyone know how to model values in a vector, which are unknown.
 > I can't use the zero value because this is a valid value. Minus
 > infinity could be an option, but I am searching for a better method
 > to handle unknown values.

Use this type for the vector elements:

type Vector_Element (Value_Known : Boolean := False) is record
    case Value_Known is
    when False =>
       null;
    when True =>
       Value : Real_Vector_Element_Type [:= Some_Useful_Default_Value];
    end case;
end record;

-- 
Jeff Carter
"When Roman engineers built a bridge, they had to stand under it
while the first legion marched across. If programmers today
worked under similar ground rules, they might well find
themselves getting much more interested in Ada!"
Robert Dewar




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

* Re: How to model unknown values in a vector?
  2003-05-31 13:43 How to model unknown values in a vector? Harald Schmidt
  2003-05-31 22:47 ` FranciKait
  2003-06-01  3:17 ` Jeffrey Carter
@ 2003-06-04  1:04 ` Nick Roberts
  2003-06-04 15:56   ` Mário Amado Alves
  2 siblings, 1 reply; 5+ messages in thread
From: Nick Roberts @ 2003-06-04  1:04 UTC (permalink / raw)


"Harald Schmidt" <harald.schmidt@anobject.net> wrote in message
news:BAFE7E15.3898%harald.schmidt@anobject.net...

> Does anyone know how to model values in a vector,
> which are unknown. I can't use the zero value
> because this is a valid value. Minus infinity could be an
> option, but I am searching for a better method to
> handle unknown values.

IEEE 745 defines loads of NaNs. If your target machine has some NaNs, and
your compiler provides some way (presumably non-standard) to get at these
values in programs, that might be a possible solution. Best of luck.

--
Nick Roberts
Jabber: debater@charente.de [ICQ: 159718630]






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

* Re: How to model unknown values in a vector?
  2003-06-04  1:04 ` Nick Roberts
@ 2003-06-04 15:56   ` Mário Amado Alves
  0 siblings, 0 replies; 5+ messages in thread
From: Mário Amado Alves @ 2003-06-04 15:56 UTC (permalink / raw)


Ah, the joys of special values :-)

  type Valid_Value is new Value
    range First_Valid_Value .. Last_Valid_Value;

  Unknown : Value := Value'Pred (First_Valid_Value); -- say

Or, the OO way

  type Value is tagged with null record;

  type Valid_Value is new Value with
    record
      The_Value : ...
    end record;

(But then you'll probably have to use pointers, and in that case there
is always null to signal unknown...)

Both are Ada ways, no implementation dependencies.



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

end of thread, other threads:[~2003-06-04 15:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-31 13:43 How to model unknown values in a vector? Harald Schmidt
2003-05-31 22:47 ` FranciKait
2003-06-01  3:17 ` Jeffrey Carter
2003-06-04  1:04 ` Nick Roberts
2003-06-04 15:56   ` Mário Amado Alves

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