Talk:24 game: Difference between revisions

Content added Content deleted
(→‎Floating point: Try 3 3 8 8 in Tcl?)
(→‎Floating point: Mixed Tcl results)
Line 37: Line 37:


::: Hi Donal, you might try [[Talk:24_game_Player#Use_3_3_8_8_in_example_runs.3F|3 3 8 8]] in the TCL example. Floating point won't work for this in Python. --[[User:Paddy3118|Paddy3118]] 14:18, 15 February 2011 (UTC)
::: Hi Donal, you might try [[Talk:24_game_Player#Use_3_3_8_8_in_example_runs.3F|3 3 8 8]] in the TCL example. Floating point won't work for this in Python. --[[User:Paddy3118|Paddy3118]] 14:18, 15 February 2011 (UTC)

::: 3 3 8 8 has different values depending on the Tcl versions it seems <lang>:> /opt/tcltk_8.0.3/bin/tclsh8.0
% expr 8.0 / ( 3.0 - 8.0 / 3.0 )
24.0
%
:> /opt/tcltk_8.3.4/bin/tclsh
% expr 8.0 / ( 3.0 - 8.0 / 3.0 )
24.0
%
:> /opt/tcltk_8.4.13/bin/tclsh
% expr 8.0 / ( 3.0 - 8.0 / 3.0 )
24.0
%
:> /opt/TWWfsw/bin/tclsh8.5
% expr 8.0 / ( 3.0 - 8.0 / 3.0 )
23.99999999999999
%</lang> --[[User:Paddy3118|Paddy3118]] 14:34, 15 February 2011 (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)
: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)