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

claptrap clap at trap.com
Wed Aug 14 07:54:15 UTC 2024


On Wednesday, 14 August 2024 at 02:35:08 UTC, Timon Gehr wrote:
> On 8/14/24 00:35, claptrap wrote:
>>
>> 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.
>> ...
>
> It is fully true. "A means B" holds when in any situation where 
> A holds, B also holds. "A does not mean B" holds when there is 
> a situation where A is true but B is false.

I'd argue "does not mean" is vague, and most people would read 
what you wrote as " A != B in any situation."

But otherwise I agree based on what you meant.


>> 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.
>> 
>
> Usually true, but I still want to decide on my own which 
> computation will be rounded to what precision. Even an 
> accidentally avoided accuracy issue resulting from not 
> guaranteed implicit higher precision is a ticking time bomb and 
> very annoying to debug when it goes off.

I agree the compiler should actually use the float precision you 
explicitly ask for.






More information about the Digitalmars-d mailing list