comp.lang.ada
 help / color / mirror / Atom feed
From: "ldries46" <bertus.dries@planet.nl>
Subject: Writing to string
Date: Thu, 2 Feb 2012 15:13:35 +0100
Date: 2012-02-02T15:13:35+01:00	[thread overview]
Message-ID: <4f2a9a63$0$4819$703f8584@textnews.kpn.nl> (raw)

In C/C++ the possibility exists to write to a string.
Is there something like that in ADA?
I want to write several floating and fixed point parameters to a string with 
each a dedicated but different number of digits behind the decimal point.
for instance a= 4.10 b= 5.2 c=7.123
In C/C++ it can be done by sprintf("a= %.2f b=%.1f c=%.3f",a,b,c);
I have seen that in Ada writing to a file or a device it can also be done 
with the PUT precedure from Text-IO but I cannot find the way to use PUT for 
outputing to a string.
I possibility that crossed my mind is using the Fixed point types but 
converting the floating point values to fixed point values in a way that I 
can use a temporary type declared like:
type number is delta fix_p(after) range <>;
where fix_p is an array (0.1, 0.01, 0.001) and after is 1, 2 or 3 doesnot 
seem to work because fix_p(after) is not static.
How can I reach my objective or should I completely write it myself?

L. Dries 




             reply	other threads:[~2012-02-02 14:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-02 14:13 ldries46 [this message]
2012-02-02 14:40 ` Writing to string AdaMagica
2012-02-02 15:57 ` Dmitry A. Kazakov
replies disabled

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