[gtkada] how to print a value with 16 bit precision

nabh4u nabh4u at yahoo.co.in
Thu Jun 12 01:55:53 CEST 2008


Hello everyone,

Gurus i need help. I am new to Ada programming. It is very urgent, please
help me. i have to submit this by tomorrow. I have a small project where i
compute the machine epsilon and i have to print the value with a 16 bit
precision. I have tried long_float and i am getting 14 bit precision but i
want a 16 bit precision. i have also tried to use type but was not
successful.

my code is:

with Ada.Text_IO,Ada.Integer_Text_IO,Ada.Long_Float_Text_IO;
use Ada.Text_IO,Ada.Integer_Text_IO,Ada.Long_Float_Text_IO;
Procedure Eps is
eps:Long_Float := 1.0;
epsp1:Long_Float;
pass:Integer := 0;
cnt:Long_Float := 1.0;
Begin
     New_Line(1);
     Put("*** Computing Machine Epsilon using Ada Language ***");
     New_Line(2);
     epsp1 := eps + 1.0;
     Put("       Pass ");
     Put("     ");
     Put(" Machine Epsilon Value ");
     New_Line(2);
     while(epsp1 > cnt) loop
          pass := pass + 1;
          eps := 0.5 * eps;
          epsp1 := eps + 1.0;
          Put(pass);
          Put("      ");
          Put(eps);
          New_Line;
     end loop;
     New_Line;
     Put("Final Eps Value : ");
     Put(eps);
     New_Line;
     Put("The Value of 1+eps+eps+eps+eps+eps+eps is : ");
     Put(cnt + eps + eps + eps + eps + eps + eps);
     New_Line;
     Put("The Value of 1+(eps+eps+eps+eps+eps+eps) is : ");
     Put(cnt + (eps + eps + eps + eps + eps + eps));
     New_Line(2);
End Eps;

-- 
View this message in context: http://www.nabble.com/how-to-print-a-value-with-16-bit-precision-tp17789846p17789846.html
Sent from the Gtk+ - Ada mailing list archive at Nabble.com.




More information about the gtkada mailing list