Undefined values: Difference between revisions

Content added Content deleted
imported>Fth
imported>Fth
Line 363: Line 363:


=={{header|Forth}}==
=={{header|Forth}}==
Forth does not have undefined values, but undefined words can be checked.
Forth does not have undefined values, but defined and undefined variables can be checked.
<syntaxhighlight lang="forth">
<syntaxhighlight lang="forth">
[undefined] var [if] .( var is undefined at first check) cr [then]
[undefined] var [if] .( var is undefined at first check) cr [then]
Line 383: Line 383:
var is undefined at third check
var is undefined at third check
</pre>
</pre>

=={{header|Fortran}}==
=={{header|Fortran}}==
Older style Fortran had no inbuilt facilities, other than a programmer adding code to recognise certain special values as "no value" or similar, so a set of valid values might be 1:20, and zero was reserved to signify "bad", or for a three-digit data field the special value 999 might be recognised, etc. Mistakes and confusions were routine, since a six-digit field might require 999999 except that value is too big for sixteen-bit integers and as a floating-point value may not be exactly expressed in binary. Averaging such values without checking for 999 (or 999999, etc.) might lead to overflow in output data fields or bad results that might be detected before publishing a report. In ''Numerical Methods That Work - Usually'', F.S. Acton remarks "The person who encoded YES, NO, DON'T CARE as one, two, three, ''respectively'' got the sort of correlations she deserved."
Older style Fortran had no inbuilt facilities, other than a programmer adding code to recognise certain special values as "no value" or similar, so a set of valid values might be 1:20, and zero was reserved to signify "bad", or for a three-digit data field the special value 999 might be recognised, etc. Mistakes and confusions were routine, since a six-digit field might require 999999 except that value is too big for sixteen-bit integers and as a floating-point value may not be exactly expressed in binary. Averaging such values without checking for 999 (or 999999, etc.) might lead to overflow in output data fields or bad results that might be detected before publishing a report. In ''Numerical Methods That Work - Usually'', F.S. Acton remarks "The person who encoded YES, NO, DON'T CARE as one, two, three, ''respectively'' got the sort of correlations she deserved."