Re: What is RoundToEx?



Hi John

You suggest we use this algorithm

Result := Round(Input*100)/100;

How does that compare to the one we use?

Result := Round(AValue / LFactor) * LFactor;

And what are the differences regarding precision?

Best regards
Dennis Kjaer Christensen

function RoundToEX_Ref(const AValue: Extended; const ADigit:
TRoundToEXRangeExtended): Extended;
var
LFactor: Extended;
CW8087 : Word;

begin
CW8087 := Get8087CW;
if (ADigit < Low(TRoundToEXRangeExtended)) or (ADigit >
High(TRoundToEXRangeExtended)) then
raise Exception.Create('ADigit out of range');
try
SetPrecisionMode(pmExtended);
SetRoundMode(rmNearest);
LFactor := IntPower(10, ADigit);
Result := Round(AValue / LFactor) * LFactor;
finally
Set8087CW(CW8087);
end;
end;


.



Relevant Pages

  • Re: What is RoundToEx?
    ... | You suggest we use this algorithm ... | How does that compare to the one we use? ... If one had infinite precision it would not make any difference. ... XanaNews Version 1.17.5.7 [Q's Salutation mod] ...
    (borland.public.delphi.language.basm)
  • Re: Parallel application ran more slowly than the sequential one?
    ... > Could you tell me what are the reasons to make an parallel application ... Your parallel algorithm may be less efficient than your serial algorithm. ... loading/unloading MPI data structures, sharing files over NFS, process ... Compare the runtime of your parallel program to ...
    (comp.parallel)
  • Re: count of each word occurred
    ... > take each word in order and compare it with the rest of the list ... Another version of this algorithm takes advantage of the fact that it does ... loop over all words in the list ... a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Reading and writing a big file in Ada (GNAT) on Windows XP
    ... common cases (no mapping, single character patterns, and so on). ... block move and compare instructions because they fouled up the pipeline and ... So in this case a better algorithm is probably the way to go (and I ... the source length is>M and the pattern length is>N, ...
    (comp.lang.ada)
  • Re: [ot?] matrix inversion
    ... >>floating point precision, badly conditioned matrices, and the ... Given M and Minv, you'd ideally have M.Minv==I, ... the challenge is to provide an algorithm ... With finite precision floats, it is already quite a challenge to ...
    (comp.lang.c)

Loading