Differences in results when using the same function in CTFE and Runtime

claptrap clap at trap.com
Tue Aug 13 22:35:20 UTC 2024


On Tuesday, 13 August 2024 at 21:03:00 UTC, Timon Gehr wrote:
> On 8/13/24 13:09, Abdulhaq wrote:
>
> At the same time, "better accuracy" is part of the reason why 
> CTFE uses higher floating-point precision, but higher precision 
> does not mean the result will be more accurate. Unless 
> arbitrary precision is used, which is even slower, it leads to 
> double-rounding issues which can cause the result to be less 
> accurate.

If you have a pristine 24 bit audio sample, maybe 120db SnR due 
to DAC limitations. Processing it in 16 bit will automatically 
loose you 4 bits of accuracy, it'll drop the SnR to 96dbs. If you 
process it at 32 bits you still have 120db SnR, greater precision 
but same accuracy as the source.

The point is the statement "higher precision does not mean the 
result will be more accurate." is only half true.

If the precision you are doing the calculations at is already 
higher than the accuracy of your data, more precision wont get 
you much of anything.

but if the converse is true, if you are processing the data at 
lower precision than the accuracy of your source data, then 
increasing precision will absolutely increase accuracy.



More information about the Digitalmars-d mailing list