How to specify output width of an PragmARC.Unbounded_Numbers.Integers big integer?

Hi;

How to specify output width of an PragmARC.Unbounded_Numbers.Integers big integer?

I don’t see any formatting options…so I’m just using a Put_Line. Would like to place a couple per line (I have 30 to display). I’d like to have a nice alignment.

Sorry if the answer is obvious…

Thanks,
Retired Build Engineer

Well, I guess it was a dumb question :frowning:

I just need to grab the first X digits as an array slice of the output image, which is a string…

Doh.

R. E. B.

I’d do something like

function Image (Value : in PragmARC.Unbounded_Numbers.Unbounded_Integer; Width : in Natural := 0) return String
with
   Post => Image'Result'Length >= Width;
-- Returns an image of Value, left padded with spaces if necessary

function Image (Value : in PragmARC.Unbounded_Numbers.Unbounded_Integer; Width : in Natural := 0) return String is
   Img : constant String := PragmARC.Unbounded_Numbers.Integers.Image (Value);
begin -- Image
   return (1 .. Width - Img'Length => ' ') & Img;
end Image;

If you want something other than spaces then you might want to treat negative numbers differently.

1 Like