Int Min



  1. Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).
  2. INTMAX and INTMIN in C/C and Applications. Difference and Similarities between PHP and C.

In C and C, INTMIN is a macro that expands to the smallest (most negative) value that can be stored in a variable of type int. In C and C, INTMAX is a macro that expands to the largest (most positive) value that can be stored in an int. On most processors INTMIN -INTMAX - 1, i.e., there is one more negative number than positive number in the range of legal values.

Predefined Constants

Core Predefined Constants

These constants are defined by the PHP core. This includes PHP, the Zend engine, and SAPI modules.

PHP_VERSION (string)
The current PHP version as a string in 'major.minor.release[extra]' notation.
PHP_MAJOR_VERSION (int)
The current PHP 'major' version as an integer (e.g., int(5) from version '5.2.7-extra').
PHP_MINOR_VERSION (int)
The current PHP 'minor' version as an integer (e.g., int(2) from version '5.2.7-extra').
PHP_RELEASE_VERSION (int)
The current PHP 'release' version as an integer (e.g., int(7) from version '5.2.7-extra').
PHP_VERSION_ID (int)
The current PHP version as an integer, useful for version comparisons (e.g., int(50207) from version '5.2.7-extra').
PHP_EXTRA_VERSION (string)
The current PHP 'extra' version as a string (e.g., '-extra' from version '5.2.7-extra'). Often used by distribution vendors to indicate a package version.
PHP_ZTS (int)
PHP_DEBUG (int)
PHP_MAXPATHLEN (int)
The maximum length of filenames (including path) supported by this build of PHP.
PHP_OS (string)
The operating system PHP was built for.
PHP_OS_FAMILY (string)
The operating system family PHP was built for. One of 'Windows', 'BSD', 'Darwin', 'Solaris', 'Linux' or 'Unknown'. Available as of PHP 7.2.0.
PHP_SAPI (string)
The Server API for this build of PHP. See also php_sapi_name().
PHP_EOL (string)
The correct 'End Of Line' symbol for this platform.
PHP_INT_MAX (int)
The largest integer supported in this build of PHP. Usually int(2147483647) in 32 bit systems and int(9223372036854775807) in 64 bit systems.
PHP_INT_MIN (int)
The smallest integer supported in this build of PHP. Usually int(-2147483648) in 32 bit systems and int(-9223372036854775808) in 64 bit systems. Usually, PHP_INT_MIN ~PHP_INT_MAX.
PHP_INT_SIZE (int)
The size of an integer in bytes in this build of PHP.
PHP_FLOAT_DIG (int)
Number of decimal digits that can be rounded into a float and back without precision loss. Available as of PHP 7.2.0.
PHP_FLOAT_EPSILON (float)
Smallest representable positive number x, so that x + 1.0 != 1.0. Available as of PHP 7.2.0.
PHP_FLOAT_MIN (float)
Smallest representable positive floating point number. If you need the smallest representable negative floating point number, use - PHP_FLOAT_MAX. Available as of PHP 7.2.0.
PHP_FLOAT_MAX (float)
Largest representable floating point number. Available as of PHP 7.2.0.
DEFAULT_INCLUDE_PATH (string)
PEAR_INSTALL_DIR (string)
PEAR_EXTENSION_DIR (string)
PHP_EXTENSION_DIR (string)
PHP_PREFIX (string)
The value --prefix was set to at configure. On Windows, it is the value --with-prefix was set to at configure.
PHP_BINDIR (string)
The value --bindir was set to at configure. On Windows, it is the value --with-prefix was set to at configure.
PHP_BINARY (string)
Specifies the PHP binary path during script execution.
PHP_MANDIR (string)
Specifies where the manpages were installed into.
PHP_LIBDIR (string)
PHP_DATADIR (string)
PHP_SYSCONFDIR (string)
PHP_LOCALSTATEDIR (string)
PHP_CONFIG_FILE_PATH (string)
PHP_CONFIG_FILE_SCAN_DIR (string)
PHP_SHLIB_SUFFIX (string)
The build-platform's shared library suffix, such as 'so' (most Unixes) or 'dll' (Windows).
PHP_FD_SETSIZE (string)
The maximum number of file descriptors for select system calls. Available as of PHP 7.1.0.
E_ERROR (int)
Error reporting constant
E_WARNING (int)
Error reporting constant
E_PARSE (int)
Error reporting constant
E_NOTICE (int)
Error reporting constant
E_CORE_ERROR (int)
Error reporting constant
E_CORE_WARNING (int)
Error reporting constant
E_COMPILE_ERROR (int)
Error reporting constant
E_COMPILE_WARNING (int)
Error reporting constant
E_USER_ERROR (int)
Error reporting constant
E_USER_WARNING (int)
Error reporting constant
E_USER_NOTICE (int)
Error reporting constant
E_RECOVERABLE_ERROR (int)
Error reporting constant.
E_DEPRECATED (int)
Error reporting constant.
E_USER_DEPRECATED (int)
Error reporting constant.
E_ALL (int)
Error reporting constant
E_STRICT (int)
Error reporting constant
__COMPILER_HALT_OFFSET__ (int)
true (bool)
See Booleans.
false (bool)
See Booleans.
null (null)
See Null.
PHP_WINDOWS_EVENT_CTRL_C (int)
A Windows CTRL+C event. Available as of PHP 7.4.0 (Windows only).
PHP_WINDOWS_EVENT_CTRL_BREAK (int)
A Windows CTRL+BREAK event. Available as of PHP 7.4.0 (Windows only).

See also: Magic constants.

Standard Predefined Constants

All constants from core extensions are defined in PHP by default.

rdcapasso
7 years ago
Int Min
Volker's getOS() function needs to have the order of cases changed in the switch statement since 'darwin' contains 'win', which means that both 'windows' and 'darwin' will return self::OS_WIN. I've moved the 'dar' case above the 'win' case:
<?php
class System {
const
OS_UNKNOWN = 1;
const
OS_WIN = 2;
const
OS_LINUX = 3;
const
OS_OSX = 4;
/**
* @return int
*/
static public function getOS() {
switch (
true) {
case
stristr(PHP_OS, 'DAR'): return self::OS_OSX;
case
stristr(PHP_OS, 'WIN'): return self::OS_WIN;
case
stristr(PHP_OS, 'LINUX'): return self::OS_LINUX;
default : return
self::OS_UNKNOWN;
}
}
}
?>
Anonymous
6 years ago
PHP_EOL can be used like that:
<?php
$data
= 'some data'.PHP_EOL;
$fp = fopen('somefile', 'a');
fwrite($fp, $data);
?>

Which is the same of rn or n depending on the OS.
You can put those lines in a while for example, and create a log file.
nabikaz at gmail dot com
4 years ago
Don't use `PHP_EOL` for textarea of form to array, use it:
array_values(array_filter(explode('n', str_replace('r', ', $_POST['data']))))
  • List of Reserved Words
importance: 2

Create a function randomInteger(min, max) that generates a random integer number from min to max including both min and max as possible values.

Int Min Java

Any number from the interval min..max must appear with the same probability.

Examples of its work:

You can use the solution of the previous task as the base.

The simple but wrong solution

The simplest, but wrong solution would be to generate a value from min to max and round it:

The function works, but it is incorrect. The probability to get edge values min and max is two times less than any other.

If you run the example above many times, you would easily see that 2 appears the most often.

That happens because Math.round() gets random numbers from the interval 1..3 and rounds them as follows:

Now we can clearly see that 1 gets twice less values than 2. And the same with 3.

The correct solution

There are many correct solutions to the task. One of them is to adjust interval borders. To ensure the same intervals, we can generate values from 0.5 to 3.5, thus adding the required probabilities to the edges:

An alternative way could be to use Math.floor for a random number from min to max+1:

Int Min Java

Now all intervals are mapped this way:

All intervals have the same length, making the final distribution uniform.