🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.comp.borland-delphi
2 messages
2 total messages Started by HJK Fri, 03 Sep 2004 07:05
Integer range
#908
Author: HJK
Date: Fri, 03 Sep 2004 07:05
30 lines
1775 bytes
Cardinal integer should work with values from 0 to 4294967296

I got a problem with large integers ( Delphi 6 , WIN2000).

var
myvalue: Cardinal

begin
myvalue:4294967296 ;
end;

I get a "Constant expression violates subrange bounds" when compiling this
code.

What I really want to do is to calculate the value of a 32-bit number from
four bytes.

myvalue:=16777216*byte3+65536*byte2+256*byte1+byte0);    hvor byte0 er LSB,
byte3 MSB.
Every byte could have the value 255.

myvalue:=16777216*255 (i.e. (2^24)*255) also results in compiler error.
My program crashed some times
when I tried to use the code for calculating 32bit value from four bytes. I
suspect that the byte3 (MSB) has got
a high value when this happen and thats why I tested with a value of 255 in
all bytes.


Anyone got a solution for this problem  ?
Re: Integer range
#909
Author: HJK
Date: Fri, 03 Sep 2004 07:18
42 lines
2210 bytes
"HJK" <nospam@online.no> wrote in message
news:MIUZc.4853$g%5.70832@news2.e.nsc.no...
> Cardinal integer should work with values from 0 to 4294967296
>
> I got a problem with large integers ( Delphi 6 , WIN2000).
>
> var
> myvalue: Cardinal
>
> begin
> myvalue:=4294967296 ;
> end;
>
> I get a "Constant expression violates subrange bounds" when compiling this
> code.
>
> What I really want to do is to calculate the value of a 32-bit number from
> four bytes.
>
> myvalue:=16777216*byte3+65536*byte2+256*byte1+byte0);    hvor byte0 er
LSB,
> byte3 MSB.
> Every byte could have the value 255.
>
> myvalue:=16777216*255 (i.e. (2^24)*255) also results in compiler error.
> My program crashed some times
> when I tried to use the code for calculating 32bit value from four bytes.
I
> suspect that the byte3 (MSB) has got
> a high value when this happen and thats why I tested with a value of 255
in
> all bytes.
>
>
> Anyone got a solution for this problem  ?
>
>

The value should be myval:=4294967295  not 4294967296
myval:=2013265920 also results in "Constant expression violates subrange
bounds"
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads