diff options
author | Tristan Gingold | 2014-11-17 21:03:49 +0100 |
---|---|---|
committer | Tristan Gingold | 2014-11-17 21:03:49 +0100 |
commit | b2e45450d8a1b96078753094b992ad8f5204474b (patch) | |
tree | a64ec74dff2d7c8f18f7470a9a3b7b0db480604e /src | |
parent | 0506aa8f9797a0b3eff751d564818cd65b7a57b5 (diff) | |
download | ghdl-b2e45450d8a1b96078753094b992ad8f5204474b.tar.gz ghdl-b2e45450d8a1b96078753094b992ad8f5204474b.tar.bz2 ghdl-b2e45450d8a1b96078753094b992ad8f5204474b.zip |
grt-images: avoid use of exponential.
Diffstat (limited to 'src')
-rw-r--r-- | src/grt/grt-images.adb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/grt/grt-images.adb b/src/grt/grt-images.adb index 342c98f..c085380 100644 --- a/src/grt/grt-images.adb +++ b/src/grt/grt-images.adb @@ -200,19 +200,23 @@ package body Grt.Images is Res_Len : constant Ghdl_Index_Type := (Len + Log_Base - 1) / Log_Base; Pos : Ghdl_Index_Type; V : Natural; - Sh : Natural range 0 .. 4; + Sh_Count : Natural range 0 .. 4; + Sh : Natural range 1 .. 16; begin Res.Base := To_Std_String_Basep (Ghdl_Stack2_Allocate (Res_Len)); V := 0; - Sh := 0; + Sh_Count := 0; + Sh := 1; Pos := Res_Len - 1; for I in reverse 1 .. Len loop - V := V + Std_Bit'Pos (Val (I - 1)) * (2 ** Sh); - Sh := Sh + 1; - if Sh = Natural (Log_Base) or else I = 1 then + V := V + Std_Bit'Pos (Val (I - 1)) * Sh; + Sh_Count := Sh_Count + 1; + Sh := Sh * 2; + if Sh_Count = Natural (Log_Base) or else I = 1 then Res.Base (Pos) := Hex_Chars (V); Pos := Pos - 1; - Sh := 0; + Sh_Count := 0; + Sh := 1; V := 0; end if; end loop; |