Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

max number

Posted on 2008-09-29
5
Medium Priority
?
208 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 2000 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 111

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

664 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