Talk:24 game: Difference between revisions

(→‎Floating point: We're in agreement)
Line 34:
% expr {(((1.0/3.0)*9.0)*8.0) - 24.0}
0.0</lang>Despite a definitely non-representable intermediate (I know the implementation) the answer is exact. I just can't trigger the problem for anything that might be a solution. (Non-solutions… who cares about them?) Rationals might be theoretically better, but IEEE double seems good enough here. –[[User:Dkf|Donal Fellows]] 13:32, 8 December 2009 (UTC)
::: You mentioned in [[Talk:24_game_Player#Should_we_enumerate_all_solutions.3F]] that it was practicable to identify all 7,860 solutions. That sounds like a pretty small test set. (Or am I misunderstanding your description of the enumeration?) --[[User:Short Circuit|Michael Mol]] 18:49, 8 December 2009 (UTC)
 
:One potential problem with floating point, when you get to more than 4 digits, is that in some languages (not Python), division by 0.0 evaluates to infinity (which can be divided by again to get 0), instead of raising an error, so for example, this in Ruby: <code>3.0 * (8.0 + 4.0 / (2.0 / (5.0 - 5.0)))</code> results in 24.0, which you might not want to allow. But I agree that this is not an issue with only 4 digits. --[[User:Spoon!|Spoon!]] 14:16, 8 December 2009 (UTC)