Eugine Savin 4 Posted November 2, 2021 Current output is 'ne', I think, it's a bug. If I explicitly set type of variable B to Currency - output will be 'eq' as expected. I use Delphi 10.4 (also please check this code in Delphi 11) program Project3; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; function GetCurrency: Currency; begin Result := 8.52; end; var A: Currency; begin A := GetCurrency; //var B: Currency := GetCurrency(); // 1 var B := GetCurrency(); // 2 if A = B then WriteLn('eq') else WriteLn('ne'); ReadLn; end. Share this post Link to post
David Heffernan 2345 Posted November 2, 2021 This is clearly a bug. Check if there is a bug report in QP, and if not submit one. Share this post Link to post
Stefan Glienke 2006 Posted November 2, 2021 (edited) Bug and already reported - all types of typekind = tkFloat getting inferred as Extended - which then causes followup errors: https://quality.embarcadero.com/browse/RSP-25799 https://quality.embarcadero.com/browse/RSP-31289 Edited November 2, 2021 by Stefan Glienke 2 Share this post Link to post
David Heffernan 2345 Posted November 2, 2021 1 hour ago, Stefan Glienke said: all float types Currency isn't a floating point type, it's a fixed point type. Sorry to be so pedantic, but you know me on this topic...... 1 Share this post Link to post
Stefan Glienke 2006 Posted November 2, 2021 1 hour ago, David Heffernan said: Currency isn't a floating point type, it's a fixed point type. Sorry to be so pedantic, but you know me on this topic...... I don't know what you mean 😉 Yes, I meant decimal type Share this post Link to post
David Heffernan 2345 Posted November 2, 2021 24 minutes ago, Stefan Glienke said: I meant decimal type That's even worse! Currency is decimal fixed, but Single, Double and Extended are all binary float! Probably you are trolling me now for fun! Share this post Link to post
Stefan Glienke 2006 Posted November 2, 2021 Whatever... all types with TypeKind = tkFloat 🤷♂️ Share this post Link to post
Lajos Juhász 293 Posted November 2, 2021 1 hour ago, David Heffernan said: Probably you are trolling me now for fun! You can test it for yourself: function GetCurrency: Currency; begin Result := 8.52; end; var A: Currency; C: double; D: extended; begin A := GetCurrency; var B := GetCurrency(); // 2 C:=GetCurrency; D:=GetCurrency; if A = B then WriteLn('A = B') else WriteLn('A <> B'); if B = C then WriteLn('B = C') else WriteLn('B <> C'); if B = D then WriteLn('B = D') else WriteLn('B <> D'); ReadLn; end. The result is: A <> B B <> C B = D Share this post Link to post
David Heffernan 2345 Posted November 2, 2021 2 hours ago, Lajos Juhász said: You can test it for yourself: You missed the point. I'm not disputing that the variable is Extended. I'm discussing the terminology decimal, binary, floating point and fixed point. Share this post Link to post