Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:47:47+00:00 2026-06-02T11:47:47+00:00

Consider: {$R+} i:= 1; While i > 0 do i:= i + 1; ShowMessage(IntToStr(i));

  • 0

Consider:

{$R+}
i:= 1;
While i > 0 do
  i:= i + 1;
ShowMessage(IntToStr(i));

If I declare i as Byte, Word, Shortint or TinyInt I get a range-check error, as expected.
If I declare i as LongWord, Cardinal, Integer, LongInt or Int64 it just goes through the while loop and gets to show the negative or 0 value, which i gets when you pass the upper bound.

Does Delphi 7 not support range checking for 32-bit and 64-bit numbers?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:47:55+00:00Added an answer on June 2, 2026 at 11:47 am

    The operation i + 1 doesn’t actually produce a range check error. The assignment operation does.

    Delphi evaluates the constant ‘1’ as an Integer and so the right hand side will produce a result that is either an Int64 or an Integer (The larger of i’s type and Integer).

    If we expand the line out we get the following

    temp := i + 1 
    i := temp
    

    temp will either be 32 or 64 bits, and will overflow if it hits the upper bound. By the time we do the assignment, we have a perfectly valid 32 or 64bit value so there’s no possibility of a range check failure if i is 32bits or more.

    If i is less than 32 bits, it will raise a range check if temp is too large to fit.

    For i >= 32bits, you can catch the overflow error like so:

    {$R+,Q+}
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code: client.Send(data, data.Length, endpoint); byte[] response = client.Receive(ref endpoint); While, according
Consider the following code: while(true) { someFunction(); Thread.sleep(1000); } What I want is that,
Consider this code: import socket store = [] scount = 0 while True: scount+=1
Consider: Dim line As String Using readFile As New StreamReader(SalesUpdateFile) While (line = readFile.ReadLine)
While architecting any n-tier intranet applications, do I have to consider anything about firewalls
Consider: Public MustInherit Class Column Public ReadOnly Property ReturnSomethingUseful() As Object Get 'return something
Can anyone tell me main steps to consider while migrating 1.1 to 3.5 windows
I've been developing for quite a while but while I consider myself competent (or
Consider the following pseudo code: def g_user(): while True: yield read_user_input() def g_socket(): while
I encountered this problem while solving a practice test Consider the following code written

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.