Jump to content
Sign in to follow this  
Skrim

Byte and Integer

Recommended Posts

Delphi 10.4

 

procedure TForm1.Button1Click(Sender: TObject);
var
  i : byte;
  j : integer;
begin

  screen.Cursor:=crHourGlass;

  try

    j:=30000;

    i:=j;

    showmessage(inttostr(i));

  finally

    screen.Cursor:=crDefault;

  end;

end;

 

If I set i=3 then inttostr gives me 3

If I set i=3000 then inttostr gives me 184

If I set i=30000 then inttostr gives me 48

 

I thought 3000 and 30000 would raise an exception, as they are out of range?

 

 

Share this post


Link to post

You should enable both range checking and overflow checking. Then you'll see your exceptions. 

Edited by David Heffernan
  • Like 1

Share this post


Link to post

Thanks, I thought they were set by default.
Moral, don't take anything for granted 🙂

 

 

Share this post


Link to post
2 hours ago, Skrim said:

Thanks, I thought they were set by default.
Moral, don't take anything for granted 🙂

 

 

They should be, don't know why Emba doesn't do this 

Share this post


Link to post
1 hour ago, Lars Fosdal said:

qp is down again 😕

Couldn't take the traffic of tens of devs trying to vote for range checking enabled by default

  • Like 1
  • Haha 3

Share this post


Link to post

Did my civic duty and helped push the server out of the mud.* Then voted for the issue.

 

 

 

 

 

* Not really

Share this post


Link to post
On 6/8/2020 at 11:40 AM, David Heffernan said:

Couldn't take the traffic of tens of devs trying to vote for range checking enabled by default

I guess it's rather a missing overflow check in the server software for the vote counter 😉
But I guess this Jira software is not written in Delphi (oh, if it were overflow checking would be available and this issue would have been caught during testing...)

 

Of course I voted for this as well.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×