Sign in Join

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

Mailing lists / fpc-pascal / 2013-01

Int64 is not an ordinal...

9 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Bart

Hi,

I tried using an Int64 as a loop variable in a for loop. The compiler complained that it was not an ordinal type.

This struck me as odd.
The docs indeed say Int64 and Word are not true ordinal types, but they seem to fit the definition given in the same document:

1. Ordinal types are countable and ordered, i.e. it is, in principle, possible to start counting them one by one, in a specified order. This property allows the operation of functions as Inc, Ord,Dec on ordinal types to be defined.
2. Ordinal values have a smallest possible value. Trying to apply the Pred function on the
smallest possible value will generate a range check error if range checking is enabled.
3. Ordinal values have a largest possible value. Trying to apply the Succ function on the largest possible value will generate a range check error if range checking is enabled.

So, why aren't Int64 and QWord "true" ordinals?

Bart

Reply by email

Michael Van Canneyt
to Bart
Bart wrote 22 lines
Hi, I tried using an Int64 as a loop variable in a for loop. The compiler complained that it was not an ordinal type. This struck me as odd. The docs indeed say Int64 and Word are not true ordinal types, but they seem to fit the definition given in the same document: 1. Ordinal types are countable and ordered, i.e. it is, in principle, possible to start counting them one by one, in a specified order. This property allows the operation of functions as Inc, Ord,Dec on ordinal types to be defined. 2. Ordinal values have a smallest possible value. Trying to apply the Pred function on the smallest possible value will generate a range check error if range checking is enabled. 3. Ordinal values have a largest possible value. Trying to apply the Succ function on the largest possible value will generate a range check error if range checking is enabled. So, why aren't Int64 and QWord "true" ordinals?

Because they don't fit in 32 bits.

Michael.

Reply by email

Florian Klämpfl
to Bart
Bart wrote 6 lines
On 1/5/13, Michael Van Canneyt wrote: > Because they don't fit in 32 bits. Which (to me) raises the question: why do "true ordinal" values have to fit in 32 bits?

Because operations like array accesses require that they fit into one register.

Reply by email

Bart
to Florian Klämpfl
Florian Klämpfl wrote
Because operations like array accesses require that they fit into one register.

OK
For the illeterate that I am, thich raises yet another dumb question: 64-bit CPU's don't have 64-bit registers?

Bart

Reply by email

Florian Klämpfl
to Bart
Bart wrote 8 lines
On 1/6/13, Florian Klämpfl wrote: > Because operations like array accesses require that they fit into one > register. OK For the illeterate that I am, thich raises yet another dumb question: 64-bit CPU's don't have 64-bit registers?

Try with a compiler for a 64 bit compiler.

Reply by email

Florian Klämpfl
to Florian Klämpfl
Florian Klämpfl wrote 11 lines
Am 06.01.2013 12:42, schrieb Bart: > On 1/6/13, Florian Klämpfl wrote: > >> Because operations like array accesses require that they fit into one >> register. > > OK > For the illeterate that I am, thich raises yet another dumb question: > 64-bit CPU's don't have 64-bit registers? Try with a compiler for a 64 bit compiler.

Try with a compiler for a 64 bit architecture ...

Reply by email

Bart
to Florian Klämpfl
Florian Klämpfl wrote
>> For the illeterate that I am, thich raises yet another dumb question: >> 64-bit CPU's don't have 64-bit registers? > > Try with a compiler for a 64 bit compiler.

Okay, now I am feeling realy stupid and embarassed. Shame on me.

Bart

Reply by email

Peter
to Bart
Bart wrote 13 lines
On 1/6/13, Florian Klämpfl wrote: >>> For the illeterate that I am, thich raises yet another dumb question: >>> 64-bit CPU's don't have 64-bit registers? >> Try with a compiler for a 64 bit compiler. Okay, now I am feeling realy stupid and embarassed. Shame on me. Bart _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Well, it had me fooled too! Maybe a bug report on the Reference Doc is warranted?

http://www.freepascal.org/docs-html/ref/refsu5.html#x27-260003.1.1 "Please note that the *qword and int64 types are not true ordinals*, so some Pascal constructs will not work with these two integer types." {/sic/}

Regards,
Peter

Reply by email