Re: [fpc-pascal] Comp type

2018-01-11 Thread greim

By the way there was a bug in fpc 3.0.
I am not sure if it is fixed yet.
Dividing a comp number by any other number gives wrong results.
Please see my posting from 29.06.2016

Markus
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Comp type

2018-01-10 Thread Tony Whyman
Thanks for the history. Comp has always puzzled me before, especially 
with these two functions from the RTL


function MSecsToTimeStamp(MSecs: Comp): TTimeStamp;
function TimeStampToMSecs(const TimeStamp: TTimeStamp): comp;

I assume that these have come down from Turbo Pascal - but it still 
seems odd that milliseconds is represented by a "real" type.


Tony Whyman


On 10/01/18 08:04, Jonas Maebe wrote:

Mattias Gaertner wrote:

Comp is Int64 div 1.

No, that is currency. Comp is a plain 64 bit integer. It originally
comes from Turbo Pascal, which did not have a regular 64 bit integer
type. The x87 fpu can be used to perform 64 bit integer math though, so
it was originally a 64 bit integer type whose calculations were
performed using the fpu.

In FPC, it's the same on platforms that still use the x87 fpu. On other
platforms, comp is an alias for the int64 type.


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Comp type

2018-01-10 Thread greim

AFAIK there is a small difference between comp and int64

COMP is 63bit + sign bit

int64 is 2s complement.

I hope I am right here.

Markus


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Comp type

2018-01-10 Thread Mattias Gaertner
On Wed, 10 Jan 2018 09:04:12 +0100
Jonas Maebe  wrote:

> Mattias Gaertner wrote:
> > Comp is Int64 div 1.  
> 
> No, that is currency. Comp is a plain 64 bit integer. It originally
> comes from Turbo Pascal, which did not have a regular 64 bit integer
> type. The x87 fpu can be used to perform 64 bit integer math though, so
> it was originally a 64 bit integer type whose calculations were
> performed using the fpu.
> 
> In FPC, it's the same on platforms that still use the x87 fpu. On other
> platforms, comp is an alias for the int64 type.

Thanks. Good to know.

I guess I got confused by the 'real' in Darius qeustion.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Comp type

2018-01-10 Thread Jonas Maebe
Mattias Gaertner wrote:
> Comp is Int64 div 1.

No, that is currency. Comp is a plain 64 bit integer. It originally
comes from Turbo Pascal, which did not have a regular 64 bit integer
type. The x87 fpu can be used to perform 64 bit integer math though, so
it was originally a 64 bit integer type whose calculations were
performed using the fpu.

In FPC, it's the same on platforms that still use the x87 fpu. On other
platforms, comp is an alias for the int64 type.


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Comp type

2018-01-09 Thread Darius Blaszyk

Comp is Int64 div 1.


Thanks for the explanation Mathias!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Comp type

2018-01-09 Thread Mattias Gaertner
On Tue, 09 Jan 2018 22:58:01 +0100
Darius Blaszyk  wrote:

> By accident I noticed the comp type for the first time. It's an Int64
> but is considered to be a real type. Just out of curiosity, what is the
> use case of such a type, or is this just implemented for compatibility
> reasons?

Comp is Int64 div 1. So it is a real, but not a float.
This has some advantages computing things like money.
For example it can represent numbers like 0.3 exactly, which is
not possible with double.
Also computing integers is often faster than doubles.

Mattias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Comp type

2018-01-09 Thread Darius Blaszyk
By accident I noticed the comp type for the first time. It's an Int64
but is considered to be a real type. Just out of curiosity, what is the
use case of such a type, or is this just implemented for compatibility
reasons?

Rgds, Darius___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal