Undefined values: Difference between revisions

m (syntax highlighting fixup automation)
imported>Fth
Line 362:
]</syntaxhighlight>
 
=={{header|Forth}}==
Forth does not have undefined values, but undefined words can be checked.
<syntaxhighlight lang="forth">
[undefined] var [if] .( var is undefined at first check) cr [then]
 
marker forget-var
 
variable var
 
[defined] var [if] .( var is defined at second check) cr [then]
 
forget-var
 
[undefined] var [if] .( var is undefined at third check) cr [then]
</syntaxhighlight>
{{out}}
<pre>
var is undefined at first check
var is defined at second check
var is undefined at third check
</pre>
=={{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."
Anonymous user