Board index » delphi » Help needed to display a real number in a readable format

Help needed to display a real number in a readable format

I am trying to diplay a calculation and am having trouble as I dont know
where the decmal place will be... It is a percentile value so always 2 dec
places, but the mantissa could be anything.  I get a really long answer at
the moment and was hoping someone knows an easier way to do this..

//cumulative Time = CumTime
//array values = arTime[0,0]
// Calculate total daily hrs from arTime[] (hrs*60 + mins)/60

      cumTime := ((arTime[0,1] - arTime[0,0])*60 + (arTime[1,1] -
arTime[1,0]))/60;
      strgWkRoster.Cells[y,2] := FloatToStr(cumTime);

I need the answer to be in 00.00 or 0000.00 style

Thanks Tony

 

Re:Help needed to display a real number in a readable format


just worked out floatstrF

sorry bout that, hate wasting peoples time, im still learning this
program....

Quote
"Tony" <gandors...@ozemail.com.au> wrote in message

news:1ZPG6.1874$VM5.57625@ozemail.com.au...
Quote
> I am trying to diplay a calculation and am having trouble as I dont know
> where the decmal place will be... It is a percentile value so always 2 dec
> places, but the mantissa could be anything.  I get a really long answer at
> the moment and was hoping someone knows an easier way to do this..

> //cumulative Time = CumTime
> //array values = arTime[0,0]
> // Calculate total daily hrs from arTime[] (hrs*60 + mins)/60

>       cumTime := ((arTime[0,1] - arTime[0,0])*60 + (arTime[1,1] -
> arTime[1,0]))/60;
>       strgWkRoster.Cells[y,2] := FloatToStr(cumTime);

> I need the answer to be in 00.00 or 0000.00 style

> Thanks Tony

Re:Help needed to display a real number in a readable format


FormatFloat is another good one

if Something then
  myMask := '0000.00'
else
  myMask := '00.00;
FormatFloat(myMask,cumTime)

Cheers
Don

On Sun, 29 Apr 2001 18:32:00 +1000, "Tony" <gandors...@ozemail.com.au>
wrote:

Quote
>just worked out floatstrF

>sorry bout that, hate wasting peoples time, im still learning this
>program....

>"Tony" <gandors...@ozemail.com.au> wrote in message
>news:1ZPG6.1874$VM5.57625@ozemail.com.au...
>> I am trying to diplay a calculation and am having trouble as I dont know
>> where the decmal place will be... It is a percentile value so always 2 dec
>> places, but the mantissa could be anything.  I get a really long answer at
>> the moment and was hoping someone knows an easier way to do this..

>> //cumulative Time = CumTime
>> //array values = arTime[0,0]
>> // Calculate total daily hrs from arTime[] (hrs*60 + mins)/60

>>       cumTime := ((arTime[0,1] - arTime[0,0])*60 + (arTime[1,1] -
>> arTime[1,0]))/60;
>>       strgWkRoster.Cells[y,2] := FloatToStr(cumTime);

>> I need the answer to be in 00.00 or 0000.00 style

>> Thanks Tony

Re:Help needed to display a real number in a readable format


In article <1ZPG6.1874$VM5.57...@ozemail.com.au>, Tony
<gandors...@ozemail.com.au> writes

Quote
>I am trying to diplay a calculation and am having trouble as I dont know
>where the decmal place will be... It is a percentile value so always 2 dec
>places, but the mantissa could be anything.  I get a really long answer at
>the moment and was hoping someone knows an easier way to do this..

>//cumulative Time = CumTime
>//array values = arTime[0,0]
>// Calculate total daily hrs from arTime[] (hrs*60 + mins)/60

>      cumTime := ((arTime[0,1] - arTime[0,0])*60 + (arTime[1,1] -
>arTime[1,0]))/60;
>      strgWkRoster.Cells[y,2] := FloatToStr(cumTime);

>I need the answer to be in 00.00 or 0000.00 style

As was said in another thread, place finger over F1 key and apply
downward pressure, then try looking for FormatFloat function. When I
first bought Delphi 1, I was sad enough to read the VCL Reference from
cover to cover...
--
Barney Tyrwhitt-Drake

Drake Software web site:  http://www.tdrake.demon.co.uk

Other Threads