comp.lang.ada
 help / color / mirror / Atom feed
* RE: Naturals and discrete types
@ 2001-11-01 23:06 Beard, Frank
  2001-11-01 23:20 ` Clueless
  0 siblings, 1 reply; 16+ messages in thread
From: Beard, Frank @ 2001-11-01 23:06 UTC (permalink / raw)
  To: 'comp.lang.ada@ada.eu.org'


-----Original Message-----
From: Clueless [mailto:chris@dont.spam.me]

> However, I'm still a little fuzzy on the best way to convert between real
> and discrete types.

      I : integer := 0;
      Y : float := 3.14;
   begin  
      I := integer(Y);  -- now I = 3;


or

      I : integer := 9;
      Y : float := 0.0;
   begin  
      Y := float(I);  -- now Y ~ 9.0;




^ permalink raw reply	[flat|nested] 16+ messages in thread
* Naturals and discrete types
@ 2001-11-01 22:05 Clueless
  2001-11-01 22:35 ` Matthew Heaney
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Clueless @ 2001-11-01 22:05 UTC (permalink / raw)


Recently I've been monkeying with the Ada.Command_Line package.

Now I'm running into trouble reading the argument count.

The Ada.Command_Line package returns a Natural type, however I've been
attempting to count the arguments using the Range attribute which expects
a discrete type.
What I've been doing is converting the Natural to an Integer using the
Value attribute. Sometimes this works, and sometimes I get an Exception.

Is it possible to get the 'Range function to accept a Natural type? Or am
I trekking down the wrong path entirely? It seems there has to be a better
way to do this.

Also, I've been checking my Ada docs to find out if the Natural type is
considered to be a Discrete or Real type by the GNAT compiler, but I
havent found any specific info yet. Although the compiler messages
certainly seem to indicate that Natural is a subtype of Real.

Forgive me if this question seems mundane. I've never really had to worry
about the difference back when I was doing C. Heh.

Any clarification, or pointers to the pertinent docs, would be helpful.

Clueless
McDoobie
chris@dont.spam.me



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

end of thread, other threads:[~2001-11-05 15:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-01 23:06 Naturals and discrete types Beard, Frank
2001-11-01 23:20 ` Clueless
2001-11-02  3:05   ` DuckE
  -- strict thread matches above, loose matches on Subject: below --
2001-11-01 22:05 Clueless
2001-11-01 22:35 ` Matthew Heaney
2001-11-01 22:59 ` Clueless
2001-11-02 15:05   ` Marin David Condic
2001-11-02 17:24 ` Ted Dennison
2001-11-02 18:19   ` Preben Randhol
2001-11-02 18:51     ` Marin David Condic
2001-11-03 18:01       ` Nick Roberts
2001-11-04  4:18         ` tmoran
2001-11-05 15:29           ` Marin David Condic
2001-11-04 11:39       ` Preben Randhol
2001-11-05  2:01         ` Clueless
2001-11-05  2:37           ` Larry Kilgallen

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