For conversion to signed types, the grammar recognized is:
Integer: Sign UnsignedInteger UnsignedInteger Sign: + -For conversion to unsigned types, the grammar recognized is:
UnsignedInteger: DecimalDigit DecimalDigit UnsignedIntegerAny deviation from that grammar causes a ConvError exception to be thrown. Any overflows cause a ConvOverflowError to be thrown.
The usual arithmetic operations can be performed on d_time, such as adding, subtracting, etc. Elapsed time in Ticks can be computed by subtracting a starting d_time from an ending d_time.
An invalid value for d_time is represented by d_time.init.
Both return the bit number of the first set bit. The return value is undefined if v is zero.
Example
import std.intrinsic;
int main()
{
uint v;
int x;
v = 0x21;
x = bsf(v);
printf("bsf(x%x) = %d\n", v, x);
x = bsr(v);
printf("bsr(x%x) = %d\n", v, x);
return 0;
}
Outputbsf(x21) = 0 bsr(x21) = 5
p is a non-NULL pointer to an array of uints. index is a bit number, starting with bit 0 of p[0], and progressing. It addresses bits like the expression:
p[index / (uint.size*8)] & (1 << (index & ((uint.size*8) - 1)))
All return a non-zero value if the bit was set, and a zero if it was clear.
Example
import std.intrinsic;
int main()
{
uint array[2];
array[0] = 2;
array[1] = 0x100;
printf("btc(array, 35) = %d\n", btc(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("btc(array, 35) = %d\n", btc(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("bts(array, 35) = %d\n", bts(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("btr(array, 35) = %d\n", btr(array, 35));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
printf("bt(array, 1) = %d\n", bt(array, 1));
printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]);
return 0;
}
Output
btc(array, 35) = 0 array = [0]:x2, [1]:x108 btc(array, 35) = -1 array = [0]:x2, [1]:x100 bts(array, 35) = 0 array = [0]:x2, [1]:x108 btr(array, 35) = -1 array = [0]:x2, [1]:x100 bt(array, 1) = -1 array = [0]:x2, [1]:x100
x | return value | invalid? |
---|---|---|
±INFINITY | NAN | yes |
x | return value | invalid? |
---|---|---|
±0.0 | ±0.0 | no |
±INFINITY | NAN | yes |
x | return value | invalid? |
---|---|---|
±0.0 | ±0.0 | no |
±INFINITY | NAN | yes |
value | x | exp |
---|---|---|
+-0.0 | +-0.0 | 0 |
+INFINITY | +INFINITY | int.max |
-INFINITY | -INFINITY | int.min |
+-NAN | +-NAN | int.min |
x | return value | divide by 0? | invalid? |
---|---|---|---|
±0.0 | -INFINITY | yes | no |
< 0.0 | NAN | no | yes |
+INFINITY | +INFINITY | no | no |
x | return value | divide by 0? | invalid? |
---|---|---|---|
±0.0 | -INFINITY | yes | no |
< 0.0 | NAN | no | yes |
+INFINITY | +INFINITY | no | no |
x | return value | invalid? |
---|---|---|
-0.0 | -0.0 | no |
<0.0 | NAN | yes |
+INFINITY | +INFINITY | no |
x | log1p(x) | divide by 0? | invalid? |
---|---|---|---|
±0.0 | ±0.0 | no | no |
-1.0 | -INFINITY | yes | no |
<-1.0 | NAN | no | yes |
+INFINITY | -INFINITY | no | no |
x | ex-1 |
---|---|
±0.0 | ±0.0 |
+INFINITY | +INFINITY |
-INFINITY | -1.0 |
sqrt(x2 + y2)Note that hypot(x,y), hypot(y,x) and hypot(x,-y) are equivalent.
x | y | return value | invalid? |
---|---|---|---|
x | +-0.0 | fabs(x) | no |
+-INFINITY | y | +INFINITY | no |
+-INFINITY | NAN | +INFINITY | no |
There are two ways to do this. The first does it all in one function call to sum(). The second is for when the data is buffered.
The routines and algorithms are derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm.
// This code is derived from the // RSA Data Security, Inc. MD5 Message-Digest Algorithm. import std.md5; import std.string; import std.c.stdio; int main(char[][] args) { for (int i = 1; i < args.length; i++) MDFile(args[i]); return 0; } /* Digests a file and prints the result. */ void MDFile(char[] filename) { FILE* file; MD5_CTX context; int len; ubyte [4 * 1024] buffer; ubyte digest[16]; if ((file = fopen(std.string.toStringz(filename), "rb")) == null) printf("%.*s can't be opened\n", filename); else { context.start(); while ((len = fread(buffer, 1, buffer.size, file)) != 0) context.update(buffer[0 .. len]); context.finish(digest); fclose(file); printf("MD5 (%.*s) = ", filename); printDigest(digest); printf("\n"); } }
The RegExp class has these methods:
Returns | Description |
---|---|
>=0 | index of match |
-1 | no match |
Attribute | Returns |
---|---|
global | same as call to exec(string) |
not global | array of all matches |
Returns | Description |
---|---|
0 | no match |
!=0 | match |
Attribute | Action |
---|---|
global | replace all matches |
not global | replace first match |
Format | Description |
---|---|
$$ | insert $ |
$& | insert the matched substring |
$` | insert the string that precedes the match |
$' | insert the string that following the match |
$n | replace with the nth parenthesized match, n is 1..9 |
$nn | replace with the nnth parenthesized match, nn is 01..99 |
$ | insert $ |
Format | Description |
---|---|
& | replace with the match |
\n | replace with the nth parenthesized match, n is 1..9 |
\c | replace with char c. |
The exact aliases are types of exactly the specified number of bits. The at least aliases are at least the specified number of bits large, and can be larger. The fast aliases are the fastest integral type supported by the processor that is at least as wide as the specified number of bits.
The aliases are:
Exact Alias | Description | At Least Alias | Description | Fast Alias | Description |
---|---|---|---|---|---|
int8_t | exactly 8 bits signed | int_least8_t | at least 8 bits signed | int_fast8_t | fast 8 bits signed |
uint8_t | exactly 8 bits unsigned | uint_least8_t | at least 8 bits unsigned | uint_fast8_t | fast 8 bits unsigned |
int16_t | exactly 16 bits signed | int_least16_t | at least 16 bits signed | int_fast16_t | fast 16 bits signed |
uint16_t | exactly 16 bits unsigned | uint_least16_t | at least 16 bits unsigned | uint_fast16_t | fast 16 bits unsigned |
int32_t | exactly 32 bits signed | int_least32_t | at least 32 bits signed | int_fast32_t | fast 32 bits signed |
uint32_t | exactly 32 bits unsigned | uint_least32_t | at least 32 bits unsigned | uint_fast32_t | fast 32 bits unsigned |
int64_t | exactly 64 bits signed | int_least64_t | at least 64 bits signed | int_fast64_t | fast 64 bits signed |
uint64_t | exactly 64 bits unsigned | uint_least64_t | at least 64 bits unsigned | uint_fast64_t | fast 64 bits unsigned |
The ptr aliases are integral types guaranteed to be large enough to hold a pointer without losing bits:
Alias | Description |
---|---|
intptr_t | signed integral type large enough to hold a pointer |
uintptr_t | unsigned integral type large enough to hold a pointer |
The max aliases are the largest integral types:
Alias | Description |
---|---|
intmax_t | the largest signed integral type |
uintmax_t | the largest unsigned integral type |
seek(0, SeekPos.Current)
or
seek(pos, SeekPos.Set)
respectively.
TS | Description |
---|---|
INITIAL | The thread hasn't been started yet. |
RUNNING | The thread is running or paused. |
TERMINATED | The thread has ended. |
PRIORITY | Description |
---|---|
INCREASE | Increase thread priority |
DECREASE | Decrease thread priority |
IDLE | Assign thread low priority |
CRITICAL | Assign thread high priority |
Note: For Win32 systems, the C wchar_t type is UTF-16 and corresponds to the D wchar type. For linux systems, the C wchar_t type is UTF-32 and corresponds to the D utf.dchar type.
UTF character support is restricted to (0 <= character <= 0x10FFFF).
ZipArchive archive = new ZipArchive(data); foreach (ArchiveMember am; archive) { printf("member name is '%.*s'\n", am.name); }