フィルターのクリア

Compatibility of Matlab with IEEE-754 1985 or 2008

3 ビュー (過去 30 日間)
christian VALPARD
christian VALPARD 2021 年 3 月 18 日
回答済み: Steven Lord 2021 年 3 月 18 日
Hi,
Is MATLAB compatible with IEEE-754 1985 or 2008 ?
-0 = +0 ? or -0 < +0
Best regards
C. VALPARD

採用された回答

Steven Lord
Steven Lord 2021 年 3 月 18 日
Is MATLAB compatible with IEEE-754 1985 or 2008 ?
There are a few operations for which the IEEE specs state what the answer should be but MATLAB returns something different. The most obvious example is the sqrt function. As stated in the IEEE Compliance section on its documentation page the IEEE spec says sqrt(aNegativeNumber) should return NaN. But since MATLAB has the capability to work with complex numbers, we return a complex answer.
There are a handful of functions that have a similar section in their documentation.
As for your specific questions related to plus and minus zero:
format hex
x = -0
x =
8000000000000000
y = 0
y =
0000000000000000
Note the differences in the sign bits.
isLT = x < y
isLT = logical
0
isEQ = x == y
isEQ = logical
1
-0 and +0 are equal.
isPosInfX = (1./x) > 0
isPosInfX = logical
0
isPosInfY = (1./y) > 0
isPosInfY = logical
1
But you can tell the sign bit by computing 1./zero and seeing if you get Inf or -Inf.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by