ERangeError is the exception for Delphi range errors.
ERangeError = class(EIntError);
class ERangeError : public EIntError;
ERangeError occurs in Delphi code when range checking is enabled and an ordinal values goes outside its declared range.
var SmallValue: 1..3; SevenBits: byte; begin; SmallValue := 4; //Won't compile: constant expression out of bounds SevenBits := 256; //Won't compile: constant expression out of bounds
end;
var SmallValue: 1..3; SevenBits: byte; ThirtyTwoBits: Integer begin; ThirtyTwoBits := 4; SmallValue := ThirtyTwoBits; //Assigns 4 to SmallValue (SmallValue is stored as a Byte) ThirtyTwoBits := 256; SevenBits := ThirtyTwoBits; //Assigns 0 to ThirtyTwoBits (high-order bits discarded)
end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|