Solved

max number

Posted on 2008-09-29
5
197 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
  • 4
5 Comments
 
LVL 7

Expert Comment

by:ahalya
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Also, you can use PHP_INT_MAX to determine the maximum size of the integer.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
@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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now