Hi Antonis

The code below will give different results from the others. Consider 
starting with 2.5996. Your solution will round up to 2.6.  Other code 
would  return 2.5. It really depends what result you actually want for 
any input.

Bobby Clarke



Antonis Tsourinakis wrote:
>
> Also you can try this
>
> function DoubleStripDigits(a:Double;dig:integer):String;
> begin
> // because format rounds, add 2 more digits then wanted
> result := format('%.*f',[dig+2, a]);
> // and then cut them
> result := copy(result,1,length(result)-2);
> end;
>
> calling as
> DoubleStripDigits(a,2)
> to have as string
> or
> StrToFloatDef(DoubleStripDigits(a,2),0)
> to have it as double
>
> *********** REPLY SEPARATOR ***********
> >Arsen Khachatryan wrote:
> >
> > Hello world how are you.
> > Im doing calculation in my delphi program for example im calculating
> > 7751.9 / 2991 and geting result 2,57970578401872 how can I cut after
> > 2.5 that its calculate like this 7751.9/2991 = 2.5 and not
> > 2,57970578401872
> >
> **************************************
>
> 
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.13/726 - Release Date: 18/03/2007 
> 15:34
>   


[Non-text portions of this message have been removed]

Reply via email to