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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -