Why am I getting false for this when the answers are equal?
>> log(3) + log(4) == log(3*4)
ans =
logical
0
>> log(3) + log(4)
ans =
2.4849
>> log(3*4)
ans =
2.4849

回答 (2 件)

the cyclist
the cyclist 2022 年 5 月 3 日
編集済み: the cyclist 2022 年 5 月 3 日

0 投票

They are equal to within double precision:
log(3) + log(4) - log(3*4)
ans = -4.4409e-16
There are many places on this forum that discuss this in more detail, e.g. this question/answer.

カテゴリ

ヘルプ センター および File Exchange で Time Series Events についてさらに検索

製品

リリース

R2018a

質問済み:

2022 年 5 月 3 日

回答済み:

2022 年 5 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by