diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-04-18 06:42:11 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-04-19 20:48:24 +0200 |
commit | 1e3f0221d1e010cadd0d844f05df63edb4534ee8 (patch) | |
tree | a70559f1c935ea84173d18ff713f539750751836 /src/grt/grt-lib.adb | |
parent | 1c4ce754b16f53442da151cb47d3b5a5ecdc5fe0 (diff) | |
download | ghdl-1e3f0221d1e010cadd0d844f05df63edb4534ee8.tar.gz ghdl-1e3f0221d1e010cadd0d844f05df63edb4534ee8.tar.bz2 ghdl-1e3f0221d1e010cadd0d844f05df63edb4534ee8.zip |
textio: use grt.fcvt to write reals.
Diffstat (limited to 'src/grt/grt-lib.adb')
-rw-r--r-- | src/grt/grt-lib.adb | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/grt/grt-lib.adb b/src/grt/grt-lib.adb index 3c16392be..9aa3558cc 100644 --- a/src/grt/grt-lib.adb +++ b/src/grt/grt-lib.adb @@ -22,6 +22,8 @@ -- covered by the GNU General Public License. This exception does not -- however invalidate any other reasons why the executable file might be -- covered by the GNU Public License. + +with Interfaces; with Grt.Errors; use Grt.Errors; with Grt.Options; with Grt.Fcvt; @@ -277,9 +279,26 @@ package body Grt.Lib is subtype Str1 is String (1 .. Natural (Str.Bounds.Dim_1.Length)); begin return Ghdl_F64 (Grt.Fcvt.From_String - (Str1 (Str.Base (0 .. Str.Bounds.Dim_1.Length)))); + (Str1 (Str.Base (0 .. Str.Bounds.Dim_1.Length - 1)))); end Textio_Read_Real; + procedure Textio_Write_Real (Str : Std_String_Ptr; + Len : Std_Integer_Acc; + V : Ghdl_F64; + Ndigits : Std_Integer) + is + -- FIXME: avoid that copy. + S : String (1 .. Natural (Str.Bounds.Dim_1.Length)); + Last : Natural; + begin + Grt.Fcvt.Format_Digits + (S, Last, Interfaces.IEEE_Float_64 (V), Natural (Ndigits)); + Len.all := Std_Integer (Last); + for I in 1 .. Last loop + Str.Base (Ghdl_Index_Type (I - 1)) := S (I); + end loop; + end Textio_Write_Real; + function Ghdl_Get_Resolution_Limit return Std_Time is begin return 1; |