comp.lang.ada
 help / color / mirror / Atom feed
* Read +Inf from file/string
@ 2002-11-06  7:21 Atle R�stad
  2002-11-06 17:23 ` Georg Bauhaus
  2002-11-06 17:38 ` Stephen Leake
  0 siblings, 2 replies; 3+ messages in thread
From: Atle R�stad @ 2002-11-06  7:21 UTC (permalink / raw)


Hi

I want to read floating-points from a file. Some of the numbers can be
+Inifinite. Is there a way to read inifinite floating points with gnat
3.13p?

There is no problem in writing (put) an infinite number this will produce
"+Inf****************",  but how can i read (get) it?

Regards
Atle





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

* Re: Read +Inf from file/string
  2002-11-06  7:21 Read +Inf from file/string Atle R�stad
@ 2002-11-06 17:23 ` Georg Bauhaus
  2002-11-06 17:38 ` Stephen Leake
  1 sibling, 0 replies; 3+ messages in thread
From: Georg Bauhaus @ 2002-11-06 17:23 UTC (permalink / raw)


"Atle R�stad" <aer@edh.ericsson.se> wrote:
: There is no problem in writing (put) an infinite number this will produce
: "+Inf****************",  but how can i read (get) it?

Afaik, you might have to check, because [an instance of float_IO].Get
"reads the longest possible sequence of characters matching
 the syntax of any of the following [numeric literals]"
 [...]
 The exception Data_Error is propagated if the sequence input
 does not have the required syntax or if the value obtained is
 not of the subtype Num.

(RM A.10.9(13,21))

You can always Get a string an then check it for Inf and then
possibly Get a numeric literal from the string using the Get
for strings.

-- georg



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

* Re: Read +Inf from file/string
  2002-11-06  7:21 Read +Inf from file/string Atle R�stad
  2002-11-06 17:23 ` Georg Bauhaus
@ 2002-11-06 17:38 ` Stephen Leake
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Leake @ 2002-11-06 17:38 UTC (permalink / raw)


"Atle R�stad" <aer@edh.ericsson.se> writes:

> Hi
> 
> I want to read floating-points from a file. Some of the numbers can be
> +Inifinite. Is there a way to read inifinite floating points with gnat
> 3.13p?

Is the file in binary or ASCII?

> There is no problem in writing (put) an infinite number this will
> produce "+Inf****************", but how can i read (get) it?

This implies you are talking about ASCII. Since that format is not
valid for Ada.Text_IO, you'll have to do something else.

I'd suggest reading each number as a string, delimited by whatever
your delimiters are. Then check for the special case of "+Inf*"; if
it's not that, call Ada.Text_IO.Get (String). If it is "+Inf*", return
the appropriate floating point value, via Unchecked_Conversion.

-- 
-- Stephe



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

end of thread, other threads:[~2002-11-06 17:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-06  7:21 Read +Inf from file/string Atle R�stad
2002-11-06 17:23 ` Georg Bauhaus
2002-11-06 17:38 ` Stephen Leake

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