Recent

Author Topic: Problem with Compare Value  (Read 2116 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 10526
Re: Problem with Compare Value
« Reply #15 on: June 28, 2020, 04:20:07 pm »
winni, correct (it is a scaled int64) but that is not how it is implemented.
It is converted to floats... see the sources.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2275
  • Compiler Developer
Re: Problem with Compare Value
« Reply #16 on: June 28, 2020, 04:20:23 pm »
The type currency is nothing but an Int64.

Not correct on i8086, i386 and x86_64 except Win64. There it is - like Comp - handled as a floating point type.

Thaddy

  • Hero Member
  • *****
  • Posts: 10526
Re: Problem with Compare Value
« Reply #17 on: June 28, 2020, 04:37:35 pm »
The type currency is nothing but an Int64.

Not correct on i8086, i386 and x86_64 except Win64. There it is - like Comp - handled as a floating point type.
Which is technically correct? ::) Unlike comp, currency is a well defined type....
e.g. https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/currency-data-type

whereas comp is a strictly Pascal type.
But I am happy with your fix, btw.
« Last Edit: June 28, 2020, 04:42:54 pm by Thaddy »

winni

  • Hero Member
  • *****
  • Posts: 1909
Re: Problem with Compare Value
« Reply #18 on: June 28, 2020, 06:00:03 pm »
@Thaddy & @PascalDragon

Sorry - my old Delphi knowledge was partly wrong.
Something learned today.

So Currency is another "Great Pretender" ...

Winni

jamie

  • Hero Member
  • *****
  • Posts: 3669
Re: Problem with Compare Value
« Reply #19 on: June 28, 2020, 10:23:28 pm »
Its still stored as a int64 and you can still code it has such...

for simple compares I have no idea why it does a Finteger load from an integer to generate a double and then perform the compare, it's kind of stupid really...

 You can cast the compare to a int64 and it works as a Int64 which comes out with the same answer or an answer I would trust better.

 most likely much faster in code too.


 Result := Int64(C1)-Int64(C2);

 Then test it it.
The only true wisdom is knowing you know nothing

PascalDragon

  • Hero Member
  • *****
  • Posts: 2275
  • Compiler Developer
Re: Problem with Compare Value
« Reply #20 on: June 29, 2020, 09:31:56 am »
for simple compares I have no idea why it does a Finteger load from an integer to generate a double and then perform the compare, it's kind of stupid really...

Because that is how Currency is defined in both FPC and Delphi.

 

TinyPortal © 2005-2018