Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-08

QWord vs. function Abs

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

Hallo,
i'm newbie and maybe making something wrong.

Small example for go32v2:

var q1,q2:qword;
begin
  q1:=10;
  q2:=20;
  writeln(Abs(q1-q2));
end.

With FPC compiler 1.0.10/IDE 0.9.2 i got this error message:

'Can't determine which overloaded function to call'

Any idea ?

With type INT64,Word it is o.k.
I think this version 1.0.x doesn't full support type QWord.

I want try the new version 1.1.x, but under Windows NT/SP6a (czech version) is not possible to start \pp\bin\go32v2\fp.exe.

Lubomír Čabla

James Mills
to Unknown author
Show quoted text 11 lines
Hallo, i'm newbie and maybe making something wrong. Small example for go32v2: var q1,q2:qword; begin q1:=10; q2:=20; writeln(Abs(q1-q2)); end.

I get runtime 215 with FPC 1.0.6 ...

This probably means that FPC cannot support qwords in the abs function even though the documentation says "Any numerical type".

Not sure though :)

cheers
James

Show quoted text 18 lines
With FPC compiler 1.0.10/IDE 0.9.2 i got this error message: 'Can't determine which overloaded function to call' Any idea ? With type INT64,Word it is o.k. I think this version 1.0.x doesn't full support type QWord. I want try the new version 1.1.x, but under Windows NT/SP6a (czech version) is not possible to start \pp\bin\go32v2\fp.exe. Lubom?r ?abla _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- -Zero Defect Software Engineers Group - ZDSEG - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape.
Peter Vreman
to James Mills
Show quoted text 16 lines
> Hallo, > i'm newbie and maybe making something wrong. > > Small example for go32v2: > > var q1,q2:qword; > begin > q1:=10; > q2:=20; > writeln(Abs(q1-q2)); > end. I get runtime 215 with FPC 1.0.6 ... This probably means that FPC cannot support qwords in the abs function even though the documentation says "Any numerical type".

The problem is that there is a abs(int64) and abs(cardinal) and it can't decide which to take. An abs(qword) needs to be added

Peter

Anton Tichawa
to Peter Vreman
you wrote 19 lines
> > Hallo, > > i'm newbie and maybe making something wrong. > > > > Small example for go32v2: > > > > var q1,q2:qword; > > begin > > q1:=10; > > q2:=20; > > writeln(Abs(q1-q2)); > > end. > >I get runtime 215 with FPC 1.0.6 ... > >This probably means that FPC cannot support qwords in the abs function >even though the documentation says "Any numerical type". The problem is that there is a abs(int64) and abs(cardinal) and it can't decide which to take. An abs(qword) needs to be added

IMHO, abs(cardinal) doesn't make any sense .. calling it could even be considered a design or coding error, couldn't it?

Anton.

----------

"Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte Berechnungen einzuweben."

Doris Langley Moore: Ada, Countess of Lovelace (London 1977).

----------

Ing. Anton Tichawa
Volkertstrasse 19 / 20
A-1020 Wien
phone: +43 1 218 97 59
email:

----------

Peter Vreman
to Anton Tichawa
you wrote 23 lines
On Wednesday 20 August 2003 16:56, you wrote: > > > Hallo, > > > i'm newbie and maybe making something wrong. > > > > > > Small example for go32v2: > > > > > > var q1,q2:qword; > > > begin > > > q1:=10; > > > q2:=20; > > > writeln(Abs(q1-q2)); > > > end. > > > >I get runtime 215 with FPC 1.0.6 ... > > > >This probably means that FPC cannot support qwords in the abs function > >even though the documentation says "Any numerical type". > > The problem is that there is a abs(int64) and abs(cardinal) and it can't > decide which to take. An abs(qword) needs to be added IMHO, abs(cardinal) doesn't make any sense .. calling it could even be considered a design or coding error, couldn't it?

Then abs(qword) also doesn't make any sense

Peter

Anton Tichawa
to Peter Vreman
you wrote 26 lines
At 18:24 20-8-2003, you wrote: >On Wednesday 20 August 2003 16:56, you wrote: > > > > Hallo, > > > > i'm newbie and maybe making something wrong. > > > > > > > > Small example for go32v2: > > > > > > > > var q1,q2:qword; > > > > begin > > > > q1:=10; > > > > q2:=20; > > > > writeln(Abs(q1-q2)); > > > > end. > > > > > >I get runtime 215 with FPC 1.0.6 ... > > > > > >This probably means that FPC cannot support qwords in the abs function > > >even though the documentation says "Any numerical type". > > > > The problem is that there is a abs(int64) and abs(cardinal) and it > > can't decide which to take. An abs(qword) needs to be added > >IMHO, abs(cardinal) doesn't make any sense .. calling it could even be >considered a design or coding error, couldn't it? Then abs(qword) also doesn't make any sense

True. So I think the best way is either to declare

var q1, q2: int64;

or, if they have to be qwords for some reason, to typecast:

writeln(abs(int64(q1) - int64(q2)));

Still, the documentation states "any numerical type". If there's time for it, FPC should imho generate a call to abs(int64) and possibly issue a warning when it encounters abs(qword).

Anton

----------

Ing. Anton Tichawa
Volkertstrasse 19 / 20
A-1020 Wien
phone: +43 1 218 97 59
email:

----------

"Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte Berechnungen einzuweben."

Doris Langley Moore: Ada, Countess of Lovelace (London 1977).

----------

Unknown author

In a file \pp\source\rtl\inc\systemh.inc dated 26.10.2002 i found (only) these declarations
about ABS function:

Function abs(l:Longint):Longint;
Function sqr(l:Longint):Longint;
Function odd(l:Longint):Boolean;
Function odd(l:Cardinal):Boolean;
{$ifdef int64}
Function odd(l:Int64):Boolean;
Function odd(l:QWord):Boolean;
function abs(l: Int64): Int64;
function sqr(l: Int64): Int64;
function sqr(l: QWord): QWord;
{$endif int64}

Thanks for all.

Lubomir Cabla/CBL