|
From: | Rik |
Subject: | Re: Single/Double precision equality |
Date: | Fri, 26 Sep 2014 21:35:54 -0700 |
On 09/26/2014 04:35 PM,
address@hidden wrote:
Look at section 4.7 of the manual "Promotion and Demotion of Data Types". I'm sure there's still room for improvement there if you want to reword things. Basically, when different types are used in a mixed operation such as A + B, then integer trumps single which trumps double. Thus, single (0.1) == double (0.1) should demote the RHS to single and then do the comparison which equals true. When doing mixed integer/floating point operations the integer is temporarily promoted to floating point and the final result is then cast back to integer (at least that is the way Matlab does it). This explains the second example because 3 (int8) is promoted to double which != pi (double). --Rik |
[Prev in Thread] | Current Thread | [Next in Thread] |