Talk:24 game: Difference between revisions

→‎Floating point: I'm not sure.
(→‎Floating point: Should work - touch wood :-))
(→‎Floating point: I'm not sure.)
Line 29:
Is recommending floating point wise? Precision and rounding errors would seem to defeat the purpose of preserving remainders. --[[User:Short Circuit|Michael Mol]] 03:58, 8 December 2009 (UTC)
: It isn't rigorous, (I'm an engineer, not a theoretical mathematician captain), but with the restricted range of single digit numbers, the given operators, and the precision of most FP implementations on a PC; I don't think it will matter. --[[User:Paddy3118|Paddy3118]] 07:12, 8 December 2009 (UTC)
: Certainly rationals are a better choice than floating point for this type of task, but I think you should be able to use floating point safely so long as you say something like <code>if abs(ans - 24) < 1e-6</code> instead of <code>if ans == 24</code>. It's considered good practice, in general, to never test a floating-point variable for exact equality. That said, I'm at a loss for an input that the Python program would wrongly reject, so maybe floating point is better than I think it is. —[[User:Underscore|Underscore]] ([[User talk:Underscore|Talk]]) 12:49, 8 December 2009 (UTC)
845

edits