Convert integer value to hexadecimal in Ada

Is there any workaround to take advantage of the following and save it?

Put_Line(MyNum, Base => 16); 

which converts, for example, 255 to its correct value in hexadecimal FF, but only for display. Can I do something similar but save the result?

+4
source share
2 answers

You can use the version Put these outputs on a line :

 procedure Put(To : out String; Item : in Num; Base : in Number_Base := Default_Base); 
+7
source

Is it possible to do something similar, but save the result?

Yes, this is not the โ€œeasiestโ€ way, but it is very general and flexible if you use Streams.

There is an example on wikibook, although it is a bit โ€œverboseโ€ for your intention: http://en.wikibooks.org/wiki/Ada_Programming/Libraries/Ada.Streams/Example


The simple "one line" is Ada.Integer_Text_IO.Put .

Ada95 RM describes integer_text_IO in Appendix A, 10.8.

+5
source

All Articles