[fpc-pascal] Power operator fails in ordinal range definition

Hairy Pixels genericptr at gmail.com
Thu Nov 14 14:44:17 CET 2024


 On Nov 14, 2024 at 8:11:53 PM, Sven Barth via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:

> Because it wasn't deemed necessary that the compiler itself provides this
> operator.
>

You can use it to create ordinal types from bytes using a generic. I was
trying to do something like this. If you do other operations on constants
it makes to include powers too. Of course you can solve this a number of
other ways too but I preferred this one.

type
  SomeInt<const A, B: Byte> = record
    header: 0..(256**A) - 1;
    footer: 0..(256**B) - 1;
  end;

SomeInt<4, 3>

Regards,
    Ryan Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20241114/216fe359/attachment.htm>


More information about the fpc-pascal mailing list