[gtkada] how to print a value with 16 bit precision
nabh4u
nabh4u at yahoo.co.in
Thu Jun 12 14:16:17 CEST 2008
Thank you Damien for the information. Is this another procedure i need to
include in my program? can you tell me how can i add this part in my code?
Thank you once again for the reply.
Damien Carbonne wrote:
>
> Hi,
>
> You are simply using default parameters of Put here:
> procedure Put
> (Item : Num;
> Fore : Field := Default_Fore;
> Aft : Field := Default_Aft;
> Exp : Field := Default_Exp);
>
> and Default_Aft is defined like that :
> Default_Aft : Field := Num'Digits - 1;
>
> As Long_Float has 15 digits, that explains the 14 printed ones.
>
> So you need to set Aft to the right value.
> It could be like that:
> Put (Foo) -> Put (Foo, Aft => 16);
>
> Damien
>
>
> nabh4u a écrit :
>> 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;
>>
>>
>
> _______________________________________________
> gtkada mailing list
> gtkada at lists.adacore.com
> http://lists.adacore.com/mailman/listinfo/gtkada
>
>
--
View this message in context: http://www.nabble.com/how-to-print-a-value-with-16-bit-precision-tp17789846p17798529.html
Sent from the Gtk+ - Ada mailing list archive at Nabble.com.
More information about the gtkada
mailing list