JensB
7/25/2011 2:16:00 AM
Jim Mack laid this down on his screen :
> Michael Cole wrote:
>> If I have two floating point numbers, what would be the easiest and
>> best (in terms of speed - this will be in a loop of up to 5000
>> items) way of comparing them based on the number with the least
>> significant figures?
>>
>> In other words
>> Comp 1.234 and 1.2343 will be equal
>> Comp 123000 and 12344.5 will be equal
>> Comp 123456 and 123450 will not
>>
>> Etc.
>>
>> Note that I do not know the number of sig figures beforehand...
>
> That sounds loopy. (-:
>
> I thought I understood what you wanted until I saw your examples. I
> can't see how all of those examples fit any one rule. Could you
> explain further?
>
> In example two, 123000 has 6 sig figs, as does its comparand. But they
> differ by an order of magnitude. In what sense are they equal?
Error in description - line should read
Comp 123000 and 123444.5 will be equal
123000 actually only has 3 sig figures, so both should round to 123000.
> Can you show (in pseudocode) the method that you're using now, to help
> clear that up?
I currently haven't implemented any.
--
Michael Cole