Ada - How to control decimal places when printing Duration data type? -
Ada - How to control decimal places when printing Duration data type? -
this print statement:
timeinmili: duration; timeinmili := (finish - start)*1000; put_line(duration'image(timeinmili)); (multiplying 1000 alter in milliseconds seconds)
the above produces alot of decimal places. can please show me illustration of how print set number of decimal places.
ada.text_io.fixed_io generic bundle fix-point types provides improve command on output format 'image attribute.
an example:
with ada.text_io; utilize ada.text_io; procedure foo bundle duration_io new fixed_io(duration); timeinmili: duration := 1.0 / 3.0; begin duration_io.put(timeinmili, fore => 0, aft => 2); new_line; end foo; output:
0.33 ada
Comments
Post a Comment