Tutorial by Examples: constants

ConstantsDescriptionApproximateMath.EBase of natural logarithm e2.718Math.LN10Natural logarithm of 102.302Math.LN2Natural logarithm of 20.693Math.LOG10EBase 10 logarithm of e0.434Math.LOG2EBase 2 logarithm of e1.442Math.PIPi: the ratio of circle circumference to diameter (π)3.14Math.SQRT1_2Square ro...
Signed integers can be of these types (the int after short, or long is optional): signed char c = 127; /* required to be 1 byte, see remarks for further information. */ signed short int si = 32767; /* required to be at least 16 bits. */ signed int i = 32767; /* required to be at least 16 bits */ ...
The C language has three mandatory real floating point types, float, double, and long double. float f = 0.314f; /* suffix f or F denotes type float */ double d = 0.314; /* no suffix denotes double */ long double ld = 0.314l; /* suffix l or L denotes long double */ /* the differen...
If you have a value that never changes in your application, you can define a named constant and use it in place of a literal value. You can use Const only at module or procedure level. This means the declaration context for a variable must be a class, structure, module, procedure, or block, and can...
math modules includes two commonly used mathematical constants. math.pi - The mathematical constant pi math.e - The mathematical constant e (base of natural logarithm) >>> from math import pi, e >>> pi 3.141592653589793 >>> e 2.718281828459045 >>> P...
You can't reassign constants. const foo = "bar"; foo = "hello"; Prints: Uncaught TypeError: Assignment to constant.
Declaring a variable const only prevents its value from being replaced by a new value. const does not put any restrictions on the internal state of an object. The following example shows that a value of a property of a const object can be changed, and even new properties can be added, because the ob...
You can initialize a constant by using the const keyword. const foo = 100; const bar = false; const person = { name: "John" }; const fun = function () = { /* ... */ }; const arrowFun = () => /* ... */ ; Important You must declare and initialize a constant in the same statement....
In Python 2, an octal literal could be defined as >>> 0755 # only Python 2 To ensure cross-compatibility, use 0o755 # both Python 2 and Python 3
Class constants provide a mechanism for holding fixed values in a program. That is, they provide a way of giving a name (and associated compile-time checking) to a value like 3.14 or "Apple". Class constants can only be defined with the const keyword - the define function cannot be used in...
If MsgBox("Click OK") = vbOK Then can be used in place of If MsgBox("Click OK") = 1 Then in order to improve readability. Use Object Browser to find available VB constants. View → Object Browser or F2 from VB Editor. Enter class to search View members available ...
Constants are created using the const statement or the define function. The convention is to use UPPERCASE letters for constant names. Define constant using explicit values const PI = 3.14; // float define("EARTH_IS_FLAT", false); // boolean const "UNKNOWN" = null; // null d...
Constants can be defined inside classes using a const keyword. class Foo { const BAR_TYPE = "bar"; // reference from inside the class using self:: public function myMethod() { return self::BAR_TYPE; } } // reference from outside the class using <Class...
EXTENDED_ARG = 145 # All opcodes greater than this have 2 operands HAVE_ARGUMENT = 90 # All opcodes greater than this have at least 1 operands cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is', 'is ... # A list of comparator id's. The indecies are used as opera...
The Number constructor has some built in constants that can be useful Number.MAX_VALUE; // 1.7976931348623157e+308 Number.MAX_SAFE_INTEGER; // 9007199254740991 Number.MIN_VALUE; // 5e-324 Number.MIN_SAFE_INTEGER; // -9007199254740991 Number.EPSILON; // 0.000...
Current file You can get the name of the current PHP file (with the absolute path) using the __FILE__ magic constant. This is most often used as a logging/debugging technique. echo "We are in the file:" , __FILE__ , "\n"; Current directory To get the absolute path to the di...
We can use Predefined Constants for Date format in date() instead of the conventional date format strings since PHP 5.1.0. Predefined Date Format Constants Available DATE_ATOM - Atom (2016-07-22T14:50:01+00:00) DATE_COOKIE - HTTP Cookies (Friday, 22-Jul-16 14:50:01 UTC) DATE_RSS - RSS (Fri, 22...
Program units often make use of literal constants. These cover the obvious cases like print *, "Hello", 1, 1.0 Except in one case, each literal constant is a scalar which has type, type parameters and value given by the syntax. Integer literal constants are of the form 1 -1 -1_1 ...
As the static keyword is used for accessing fields and methods without an instantiated class, it can be used to declare constants for use in other classes. These variables will remain constant across every instantiation of the class. By convention, static variables are always ALL_CAPS and use unders...
You can declare multiple constants within the same const block: const ( Alpha = "alpha" Beta = "beta" Gamma = "gamma" ) And automatically increment constants with the iota keyword: const ( Zero = iota // Zero == 0 One // One == 1...

Page 1 of 2