Infinity: Difference between revisions

277 bytes added ,  14 years ago
→‎{{header|MATLAB}}: Added an explanation and changed the sample code.
(→‎Python: Another way)
(→‎{{header|MATLAB}}: Added an explanation and changed the sample code.)
Line 351:
 
=={{header|MATLAB}}==
MATLAB implements the IEEE 754 floating point standard as the default for all numeric data types. +Inf and -Inf are by default implemented and supported by MATLAB. To check if a variable has the value +/-Inf, one can use the built-in function "isinf()" which will return a Boolean 1 if the number is +/-inf.
<lang Matlab>function [hasInfinity] = checkforinfinity()
 
if ( isinf(inf) == 1 )
<lang Matlab>a = +Inf;
hasInfinity = 1;
isinf(a);
end</lang>
 
Returns:
<lang Matlab>
ans =
 
1
</lang>
 
=={{header|Metafont}}==
Anonymous user