Sign in Join

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

Mailing lists / fpc-pascal / 2002-06

Cardinal Assignment

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Chuck welch

Hello,

With fpc 1.0.4 the following compiles ok on linux:

var
  card : cardinal;
Begin
  card := 3858954154;
end.

But under 1.0.6 I get a "Incompatible types: got "S80REAL" expected "ULONG"

Trying to do a card := Round() or Trunc results in a range check error.

How can I assign a value this large to a cardinal?

Thanks

Chuck

Jonas Maebe
to Chuck welch
Chuck welch wrote 9 lines
With fpc 1.0.4 the following compiles ok on linux: var card : cardinal; Begin card := 3858954154; end.

The reason is that

a) the 1.0.x compiler handles all integer constants as longints internally b) val() for longints was broken in 1.0.4, in that it accepted cardinal values
c) range checking for cardinal-longint conversions was not implemented

But under 1.0.6 I get a "Incompatible types: got "S80REAL" expected "ULONG"

Indeed, now the compiler detects that that is not a valid longint value, so it parses it as a floating point number.

Trying to do a card := Round() or Trunc results in a range check error.

That's because round() and trunc() also return longints in 1.0.4 I think (and even if they didn't, this expression would be evaluated at compile time, so the result would be stored internally again as a longint, giving the same result).

How can I assign a value this large to a cardinal?

I think the only way is to use hex notation and then adding an explicit cardinal() typecast round the value.

Jonas

ron wilson
to Chuck welch: With fpc 1.0.4 the following compiles ok on linux: var card : cardinal; Begin card :=…

i know that DDE is windows specific, but can someone point me in the right direction? i would like to write a console-app that can send dde commands to dde compliant windows applications.

kind regards,
ron wilson.

Earlier message 34 lines
-----Original Message----- From: Behalf Of Chuck welch Sent: Thursday, June 20, 2002 6:55 PM To: Subject: [fpc-pascal]Cardinal Assignment Hello, With fpc 1.0.4 the following compiles ok on linux: var card : cardinal; Begin card := 3858954154; end. But under 1.0.6 I get a "Incompatible types: got "S80REAL" expected "ULONG" Trying to do a card := Round() or Trunc results in a range check error. How can I assign a value this large to a cardinal? Thanks Chuck