Solved

max number

Posted on 2008-09-29
5
204 Views
Last Modified: 2008-09-29
hello there,
I have this code but I would like to know what will be the max number I can have.. as of now I have it set to 151
will it be possible to have it over millions or it will take up high loads on the server and memory?
$checkthisnumber = '50';
 
$i=1;
while ($i < 151) 
{
        
 if ($i == $checkthisnumber) 
        {
                echo $checkthisnumber . ' number found';
                break;
        }
$i++;
}

Open in new window

0
Comment
Question by:XK8ER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 7

Expert Comment

by:ahalya
ID: 22595757
Well, it depends on the type of "i"

if you are looking for smaller ranges then use byte or word

If the type of i is

byte: 0..255  (8 bit)
word: 0..65535 (16 bit)

You can have much larger ranges by using integer, longint, cardinal etc. See Delphi's help file for the ranges.

The loop takes longer to execute with a higher number, but there is no concern in terms of memory.  
0
 
LVL 7

Accepted Solution

by:
ahalya earned 500 total points
ID: 22595767
From Delphi Help:

Shortint      -128..127      signed 8-bit
Smallint      -32768..32767      signed 16-bit
Longint      -2147483648..2147483647      signed 32-bit
Int64      -2^63..2^63-1      signed 64-bit
Byte      0..255      unsigned 8-bit
Word      0..65535      unsigned 16-bit
Longword      0..4294967295      unsigned 32-bit
0
 
LVL 7

Expert Comment

by:ahalya
ID: 22595802
ouch, sorry. I thought I was in the Delphi forum.  For php, the maxsize is dependent on the platform. but in most cases it will be 32-bits.

Which is to say that you can go from -2147483648 to 2147483647. (in most cases)

0
 
LVL 7

Expert Comment

by:ahalya
ID: 22595811
Also, you can use PHP_INT_MAX to determine the maximum size of the integer.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22597108
@XK8ER: You can count up to very high numbers, but I am curious... What is the intended purpose of the example you posted above?  It looks like it is just loops, adding one until it comes to (drum roll) a number you ALREADY KNOW!  Please tell us a little more about your objectives.

To answer your direct question, yes it will place a load on the processor, and no, it will not place a load on memory.

See the man page here for info on largest integers:
http://us3.php.net/manual/tr/reserved.constants.php
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question