IGOR_IGOR
IGOR_IGOR

Reputation: 41

Why Free Pascal prints 'NO'?

var
    a: Integer;  
begin 
    a:= 300;  
    if a in [100..500] then  
        WriteLn ('YES')    
    else  
        WriteLn ('NO')  
end.

Upvotes: 2

Views: 111

Answers (1)

Ken White
Ken White

Reputation: 125679

Pascal supports only numbers between 0 and 255 in sets, according to the FreePascal documentation. The significant portion is here:

Each of the elements of SetType must be of type TargetType. TargetType can be any ordinal type with a range between 0 and 255. A set can contain at most 255 elements.

Turning on range checking {$R+} will cause the compiler to warn you of these sorts of errors.

Upvotes: 8

Related Questions