mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.cosmetics, .docs
git-svn-id: svn://ultimatepp.org/upp/trunk@10506 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
745ca84d0b
commit
ceed320454
5 changed files with 194 additions and 185 deletions
|
|
@ -1,24 +1,34 @@
|
|||
unsigned stou(const char *ptr, void *endptr = NULL, unsigned base = 10);
|
||||
inline unsigned stou(const byte *ptr, void *endptr = NULL, unsigned base = 10) { return stou((const char *)ptr, endptr, base); }
|
||||
unsigned stou(const wchar *ptr, void *endptr = NULL, unsigned base = 10);
|
||||
unsigned stou(const char *ptr, void *endptr = NULL, unsigned radix = 10);
|
||||
inline unsigned stou(const byte *ptr, void *endptr = NULL, unsigned radix = 10) { return stou((const char *)ptr, endptr, radix); }
|
||||
unsigned stou(const wchar *ptr, void *endptr = NULL, unsigned radix = 10);
|
||||
|
||||
uint64 stou64(const char *s, void *endptr = NULL, unsigned base = 10);
|
||||
uint64 stou64(const wchar *s, void *endptr = NULL, unsigned base = 10);
|
||||
uint64 stou64(const char *s, void *endptr = NULL, unsigned radix = 10);
|
||||
uint64 stou64(const wchar *s, void *endptr = NULL, unsigned radix = 10);
|
||||
|
||||
int ScanInt(const char *ptr, const char **endptr = NULL, int radix = 10);
|
||||
int ScanInt(const wchar *ptr, const wchar **endptr = NULL, int radix = 10);
|
||||
|
||||
int64 ScanInt64(const char *ptr, const char **endptr = NULL, int base = 10);
|
||||
int64 ScanInt64(const char *ptr, const char **endptr = NULL, int radix = 10);
|
||||
|
||||
double ScanDouble(const char *ptr, const char **endptr = NULL, bool accept_comma = true);
|
||||
double ScanDouble(const wchar *ptr, const wchar **endptr = NULL, bool accept_comma = true);
|
||||
|
||||
Value StrIntValue(const char *s);
|
||||
inline int StrInt(const char* s) { return ScanInt(s); }
|
||||
inline double IntDbl(int i) { return IsNull(i) ? double(Null) : double(i); }
|
||||
inline int DblInt(double d) { return IsNull(d) ? int(Null) : fround(d); }
|
||||
Value StrDblValue(const char* s);
|
||||
inline double StrDbl(const char* s) { return ScanDouble(s); }
|
||||
|
||||
inline int StrInt(const char* s) { return ScanInt(s); }
|
||||
inline String IntStr(int i) { return FormatInt(i); }
|
||||
|
||||
inline int64 StrInt64(const char *s) { return ScanInt64(s); }
|
||||
inline String IntStr64(int64 i) { return FormatInt64(i); }
|
||||
|
||||
inline double StrDbl(const char* s) { return ScanDouble(s); }
|
||||
inline String DblStr(double d) { return FormatDouble(d, 10); }
|
||||
|
||||
inline double IntDbl(int i) { return IsNull(i) ? double(Null) : double(i); }
|
||||
inline int DblInt(double d) { return IsNull(d) ? int(Null) : fround(d); }
|
||||
|
||||
Value StrDblValue(const char* s);
|
||||
|
||||
|
||||
Value NotNullError();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ inline String FormatHex(const void *ptr) { return FormatIntHex((int)(uintptr
|
|||
#endif
|
||||
|
||||
String FormatInteger(int a);
|
||||
String FormatInt64(int64 a);
|
||||
String FormatUnsigned(unsigned long a);
|
||||
String FormatDouble(double a);
|
||||
String FormatBool(bool a);
|
||||
String FormatInt64(int64 a);
|
||||
|
||||
template<> inline String AsString(const short& a) { return FormatInteger(a); }
|
||||
template<> inline String AsString(const unsigned short& a) { return FormatUnsigned(a); }
|
||||
|
|
@ -55,10 +55,6 @@ String FormatDoubleExp(double d, int digits, int flags = 0, int fill_exp
|
|||
String FormatDate(Date date, const char *format, int language = 0);
|
||||
String FormatTime(Time time, const char *format, int language = 0);
|
||||
|
||||
inline String IntStr(int i) { return FormatInt(i); }
|
||||
inline String IntStr64(int64 i) { return FormatInt64(i); }
|
||||
inline String DblStr(double d) { return FormatDouble(d, 10); }
|
||||
|
||||
/*
|
||||
Date ScanDate(const char *text, const char **endptr, const char *format, int language, Date base_date);
|
||||
Time ScanTime(const char *text, const char **endptr, const char *format, int language, Time base_time);
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ values are in range).&]
|
|||
[s4; &]
|
||||
[s5;:Time`:`:AsFileTime`(`)const: [_^FileTime^ FileTime]_[* AsFileTime]()_[@(0.0.255) const
|
||||
]&]
|
||||
[s2;%% Converst the time into a system specific value.&]
|
||||
[s2;%% Converts the time into a system specific value.&]
|
||||
[s3; &]
|
||||
[s0; &]
|
||||
[s0; &]
|
||||
|
|
@ -291,7 +291,7 @@ har]_`*[*@3 s])&]
|
|||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:GetLeapSeconds`(Date`): [@(0.0.255) int]_[* GetLeapSeconds]([_^Date^ Date]_[*@3 dt])&]
|
||||
[s2;%% Returns the number of leap seconds that has occured since
|
||||
[s2;%% Returns the number of leap seconds that has occurred since
|
||||
the start of adding leap seconds till [%-*@3 dt].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
|
|
|
|||
|
|
@ -9,132 +9,131 @@ topic "Formatting functions";
|
|||
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
|
||||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[{_}%EN-US
|
||||
[s0; [*@3;4 Formatting functions]&]
|
||||
[{_}
|
||||
[ {{10000@(113.42.0) [s0;%% [*@7;4 Number formatting]]}}&]
|
||||
[s3; &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0; [* Global functions]]}}&]
|
||||
[s3;%- &]
|
||||
[s5;:FormatInt`(int`):%- [_^String^ String]_[* FormatInt]([@(0.0.255) int]_[*@3 i])&]
|
||||
[s2; Outputs decimally formatted signed integer [%-*@3 i] without `+
|
||||
or any paddings. Supposed to be quite fast. Equivalent to FormatIntBase(i,
|
||||
10).&]
|
||||
[s3;* &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatIntBase`(int`,int`,int`,char`,int`,bool`):%- String_[* FormatIntBase]([@(0.0.255) i
|
||||
nt]_[*@3 i], [@(0.0.255) int]_[*@3 base], [@(0.0.255) int]_[*@3 width]_`=_[@3 0],
|
||||
[s5;:FormatIntBase`(int`,int`,int`,char`,int`,bool`): String_[* FormatIntBase]([@(0.0.255) i
|
||||
nt]_[*@3 i], [@(0.0.255) int]_[*@3 radix], [@(0.0.255) int]_[*@3 width]_`=_[@3 0],
|
||||
[@(0.0.255) char]_[*@3 lpad]_`=_`'_`', [@(0.0.255) int]_[*@3 sign]_`=_[@3 0],
|
||||
[@(0.0.255) bool]_[*@3 upper]_`=_[@(0.0.255) false])&]
|
||||
[s2; Formats a signed or unsigned integer [%-*@3 i] in a given radix
|
||||
[%-*@3 base] with left padding to given [%-*@3 width] with a given
|
||||
[%-*@3 lpad] character. If [*@3 sign ]is `+1 `= always prepend `'`+`'/`-,
|
||||
if 0 `= auto (`'`-`' only), if `-1, format as unsigned. If [%-*@3 upper]
|
||||
is true, letters for base > 10 are uppercase.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatIntDec`(int`,int`,char`,bool`):%- [_^String^ String]_[* FormatIntDec]([@(0.0.255) i
|
||||
[s2;%% Formats a signed or unsigned integer [%-*@3 i] in a given [%-*@3 radix]
|
||||
with left padding to given [%-*@3 width] with a given [%-*@3 lpad]
|
||||
character. If [*@3 sign ]is `+1 `= always prepend `'`+`'/`-, if
|
||||
0 `= auto (`'`-`' only), if `-1, format as unsigned. If [%-*@3 upper]
|
||||
is true, letters for base > 10 are uppercase. If [%-*@3 i] is Null,
|
||||
returns empty String.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatInt`(int`): [_^String^ String]_[* FormatInt]([@(0.0.255) int]_[*@3 i])&]
|
||||
[s2;%% Outputs decimally formatted signed integer [%-*@3 i] without
|
||||
`+ or any paddings. Supposed to be quite fast. Equivalent to
|
||||
FormatIntBase(i, 10).&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatIntDec`(int`,int`,char`,bool`): [_^String^ String]_[* FormatIntDec]([@(0.0.255) i
|
||||
nt]_[*@3 i], [@(0.0.255) int]_[*@3 width], [@(0.0.255) char]_[*@3 lpad]_`=_`'_`',
|
||||
[@(0.0.255) bool]_[*@3 always`_sign]_`=_[@(0.0.255) false])&]
|
||||
[s2; Formats a signed decimal integer [%-*@3 i] with left padding up
|
||||
to given [%-*@3 width] characters (output longer than this is not
|
||||
padded) with a given [%-*@3 lpad] character. If [%-*@3 always`_sign
|
||||
[s2;%% Formats a signed decimal integer [%-*@3 i] with left padding
|
||||
up to given [%-*@3 width] characters (output longer than this is
|
||||
not padded) with a given [%-*@3 lpad] character. If [%-*@3 always`_sign
|
||||
]is true, start positive numbers with `'`+`' (negative numbers
|
||||
always start with `'`-`').&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatIntHex`(int`,int`,char`):%- [_^String^ String]_[* FormatIntHex]([@(0.0.255) int]_
|
||||
[*@3 i], [@(0.0.255) int]_[*@3 width]_`=_[@3 8], [@(0.0.255) char]_[*@3 lpad]_`=_`'[@3 0]`')&]
|
||||
[s2;~~~.1152; Formats an unsigned hexadecimal (radix 16) integer
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatIntHex`(int`,int`,char`): [_^String^ String]_[* FormatIntHex]([@(0.0.255) int]_[*@3 i
|
||||
], [@(0.0.255) int]_[*@3 width]_`=_[@3 8], [@(0.0.255) char]_[*@3 lpad]_`=_`'[@3 0]`')&]
|
||||
[s2;~~~.1152;%% Formats an unsigned hexadecimal (radix 16) integer
|
||||
[%-*@3 i] with left padding up to given [%-*@3 width] characters
|
||||
(output longer than this is not padded) with a given [%-*@3 lpad]
|
||||
character.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatIntOct`(int`,int`,char`):%- [_^String^ String]_[* FormatIntOct]([@(0.0.255) int]_
|
||||
[*@3 i], [@(0.0.255) int]_[*@3 width]_`=_[@3 12], [@(0.0.255) char]_[*@3 lpad]_`=_`'[@3 0]`')&]
|
||||
[s2; Formats an unsigned octal (radix 8) integer [%-*@3 i] with left
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatIntOct`(int`,int`,char`): [_^String^ String]_[* FormatIntOct]([@(0.0.255) int]_[*@3 i
|
||||
], [@(0.0.255) int]_[*@3 width]_`=_[@3 12], [@(0.0.255) char]_[*@3 lpad]_`=_`'[@3 0]`')&]
|
||||
[s2;%% Formats an unsigned octal (radix 8) integer [%-*@3 i] with left
|
||||
padding up to given [%-*@3 width] characters (output longer than
|
||||
this is not padded) with a given [%-*@3 lpad] character.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatIntRoman`(int`,bool`):%- [_^String^ String]_[* FormatIntRoman]([@(0.0.255) int]_
|
||||
[*@3 i], [@(0.0.255) bool]_[*@3 upper]_`=_[@(0.0.255) false])&]
|
||||
[s2; Formats a signed integer [%-*@3 i] in Roman numerals. The biggest
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatIntRoman`(int`,bool`): [_^String^ String]_[* FormatIntRoman]([@(0.0.255) int]_[*@3 i
|
||||
], [@(0.0.255) bool]_[*@3 upper]_`=_[@(0.0.255) false])&]
|
||||
[s2;%% Formats a signed integer [%-*@3 i] in Roman numerals. The biggest
|
||||
`"implemented`" numeral is M (1000), so expect quite a long return
|
||||
string when formatting a billion. Negative numbers are prepended
|
||||
with `[`-`], 0 or Null is output as a Null String. If [%-*@3 upper]
|
||||
is true, use uppercase `[true`] or lowercase `[false`] letters&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatIntAlpha`(int`,bool`):%- [_^String^ String]_[* FormatIntAlpha]([@(0.0.255) int]_
|
||||
[*@3 i], [@(0.0.255) bool]_[*@3 upper]_`=_[@(0.0.255) true])&]
|
||||
[s2; Formats a signed integer [%-*@3 i] in length`-first lexicographic
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatIntAlpha`(int`,bool`): [_^String^ String]_[* FormatIntAlpha]([@(0.0.255) int]_[*@3 i
|
||||
], [@(0.0.255) bool]_[*@3 upper]_`=_[@(0.0.255) true])&]
|
||||
[s2;%% Formats a signed integer [%-*@3 i] in length`-first lexicographic
|
||||
index, i.e. excel column numbering (1 `= A,2 `= B.. 26 `= Z,
|
||||
27 `= AA, 28 `= AB .. 52 `= AZ, 53 `= BA ... 78 `= BZ etc). 0
|
||||
or Null is output as a Null String. Only negative numbers are
|
||||
prepended with a `[`-`]. If [%-*@3 upper] is true, use uppercase
|
||||
letter.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Format64`(uint64`):%- [_^String^ String]_[* Format64]([_^uint64^ uint64]_[*@3 a])&]
|
||||
[s2; Formats an unsigned decimal 64`-bit integer [%-*@3 a]. Supposed
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Format64`(uint64`): [_^String^ String]_[* Format64]([_^uint64^ uint64]_[*@3 a])&]
|
||||
[s2;%% Formats an unsigned decimal 64`-bit integer [%-*@3 a]. Supposed
|
||||
to be quite fast.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:Format64Hex`(uint64`):%- [_^String^ String]_[* Format64Hex]([_^uint64^ uint64]_[*@3 a])&]
|
||||
[s2; Formats an unsigned hexadecimal [%-*@3 a] (radix 16) 64`-bit integer.
|
||||
Supposed to be quite fast. Lowecase letters a`-f are used for
|
||||
digits `[10`] through `[15`].&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatIntHex`(const void`*`):%- [_^String^ String]_[* FormatIntHex]([@(0.0.255) const]_
|
||||
[@(0.0.255) void]_`*[*@3 ptr])&]
|
||||
[s2; Formats the pointer address [%-*@3 ptr] as a hexadecimal (base
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Format64Hex`(uint64`): [_^String^ String]_[* Format64Hex]([_^uint64^ uint64]_[*@3 a])&]
|
||||
[s2;%% Formats an unsigned hexadecimal [%-*@3 a] (radix 16) 64`-bit
|
||||
integer. Supposed to be quite fast. Lowecase letters a`-f are
|
||||
used for digits `[10`] through `[15`].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatIntHex`(const void`*`): [_^String^ String]_[* FormatIntHex]([@(0.0.255) const]_[@(0.0.255) v
|
||||
oid]_`*[*@3 ptr])&]
|
||||
[s2;%% Formats the pointer address [%-*@3 ptr] as a hexadecimal (base
|
||||
16) number zero`-padded to the number of digits appropriate for
|
||||
the memory model (8 digits in 32`-bit systems, 16 digits in 64`-bit
|
||||
systems). Useful for logging and debugging purposes. Equivalent
|
||||
to FormatHex, god knows why there are two of them.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatHex`(const void`*`):%- [_^String^ String]_[* FormatHex]([@(0.0.255) const]_[@(0.0.255) v
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatHex`(const void`*`): [_^String^ String]_[* FormatHex]([@(0.0.255) const]_[@(0.0.255) v
|
||||
oid]_`*[*@3 ptr])&]
|
||||
[s2; Same as FormatIntHex.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatInteger`(int`):%- [_^String^ String]_[* FormatInteger]([@(0.0.255) int]_[*@3 a])&]
|
||||
[s2; Formats a signed decimal integer without padding. In comparison
|
||||
[s2;%% Same as FormatIntHex.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatInteger`(int`): [_^String^ String]_[* FormatInteger]([@(0.0.255) int]_[*@3 a])&]
|
||||
[s2;%% Formats a signed decimal integer without padding. In comparison
|
||||
to FormatInt it returns String(Null) when given int(Null) whereas
|
||||
FormatInt returns a plain empty string.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatUnsigned`(unsigned long`):%- [_^String^ String]_[* FormatUnsigned]([@(0.0.255) u
|
||||
nsigned]_[@(0.0.255) long]_[*@3 a])&]
|
||||
[s2; A very old freak, implemented through Sprintf(`"%u`", a). Deprecated.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatDouble`(double`):%- [_^String^ String]_[* FormatDouble]([@(0.0.255) double]_[*@3 a
|
||||
])&]
|
||||
[s2; Formats a floating point [%-*@3 a] in decimal notation automatically
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatUnsigned`(unsigned long`): [_^String^ String]_[* FormatUnsigned]([@(0.0.255) uns
|
||||
igned]_[@(0.0.255) long]_[*@3 a])&]
|
||||
[s2;%% A very old freak, implemented through Sprintf(`"%u`", a).
|
||||
Deprecated.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatDouble`(double`): [_^String^ String]_[* FormatDouble]([@(0.0.255) double]_[*@3 a])
|
||||
&]
|
||||
[s2;%% Formats a floating point [%-*@3 a] in decimal notation automatically
|
||||
selecting ordinary or scientific (exponential) notation according
|
||||
to the absolute value of a. In ordinary notation, the number
|
||||
is formatted to 10 significant digits; in exponential notation,
|
||||
the mantissa is formatted to 10 decimal digits.&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatBool`(bool`):%- [_^String^ String]_[* FormatBool]([@(0.0.255) bool]_[*@3 a])&]
|
||||
[s2; Formats a boolean [%-*@3 a] as one of the fixed words `"true`"
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatBool`(bool`): [_^String^ String]_[* FormatBool]([@(0.0.255) bool]_[*@3 a])&]
|
||||
[s2;%% Formats a boolean [%-*@3 a] as one of the fixed words `"true`"
|
||||
or `"false`" (regardless of language settings).&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatInt64`(int64`):%- [_^String^ String]_[* FormatInt64]([_^int64^ int64]_[*@3 a])&]
|
||||
[s2; Formats a signed decimal 64`-bit integer [%-*@3 a] without any
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatInt64`(int64`): [_^String^ String]_[* FormatInt64]([_^int64^ int64]_[*@3 a])&]
|
||||
[s2;%% Formats a signed decimal 64`-bit integer [%-*@3 a] without any
|
||||
padding. Only negative numbers are prepended with a `[`-`].&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatDouble`(double`,int`,int`,int`):%- [_^String^ String]_[* FormatDouble]([@(0.0.255) d
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatDouble`(double`,int`,int`,int`): [_^String^ String]_[* FormatDouble]([@(0.0.255) d
|
||||
ouble]_[*@3 d], [@(0.0.255) int]_[*@3 digits], [@(0.0.255) int]_[*@3 flags]_`=_[@3 0],
|
||||
[@(0.0.255) int]_[*@3 fill`_exp]_`=_[@3 0])&]
|
||||
[s2; Formats a floating point number [%-*@3 d] in decimal notation
|
||||
[s2;%% Formats a floating point number [%-*@3 d] in decimal notation
|
||||
automatically selecting ordinary or scientific (exponential)
|
||||
notation according to the absolute value of a and the given number
|
||||
of [%-*@3 digits]. In the (default) absolute decimal mode, a number
|
||||
|
|
@ -144,66 +143,66 @@ decimal mode (FD`_REL), a number is formatted in exponential
|
|||
notation whenever its absolute value exceeds the interval `[10`^`-<2
|
||||
`* digits>, 10`^`+<2 `* digits>`]. [%-*@3 flags] can be a binary
|
||||
combination ([@(0.0.255) `|]) of&]
|
||||
[s0; &]
|
||||
[ {{2098:7902<288;h1; [s0; FD`_SIGN]
|
||||
:: [s0; [/ always prepend sign (`+10)]]
|
||||
:: [s0; FD`_REL]
|
||||
:: [s0; [/ relative decimal places (valid digits)]]
|
||||
:: [s0; FD`_SIGN`_EXP]
|
||||
:: [s0; [/ always prepend sign to exponent (1e`+2)]]
|
||||
:: [s0; FD`_CAP`_E]
|
||||
:: [s0; [/ capital E for exponent (1E10)]]
|
||||
:: [s0; FD`_ZERO]
|
||||
:: [s0; [/ keep trailing zeros (1.25000)]]
|
||||
:: [s0; FD`_FIX]
|
||||
:: [s0; [/ always use fixed notation (FormatDouble only)]]
|
||||
:: [s0; FD`_EXP]
|
||||
:: [s0; [/ always use exponential notation (FormatDouble only)]]}}&]
|
||||
[s2; &]
|
||||
[s2; [*@3 fill`_exp ]is left zero`-padding of exponent in exponential
|
||||
[s0;%% &]
|
||||
[ {{2098:7902<288;h1; [s0;%% FD`_SIGN]
|
||||
:: [s0;%% [/ always prepend sign (`+10)]]
|
||||
:: [s0;%% FD`_REL]
|
||||
:: [s0;%% [/ relative decimal places (valid digits)]]
|
||||
:: [s0;%% FD`_SIGN`_EXP]
|
||||
:: [s0;%% [/ always prepend sign to exponent (1e`+2)]]
|
||||
:: [s0;%% FD`_CAP`_E]
|
||||
:: [s0;%% [/ capital E for exponent (1E10)]]
|
||||
:: [s0;%% FD`_ZERO]
|
||||
:: [s0;%% [/ keep trailing zeros (1.25000)]]
|
||||
:: [s0;%% FD`_FIX]
|
||||
:: [s0;%% [/ always use fixed notation (FormatDouble only)]]
|
||||
:: [s0;%% FD`_EXP]
|
||||
:: [s0;%% [/ always use exponential notation (FormatDouble only)]]}}&]
|
||||
[s2;%% &]
|
||||
[s2;%% [*@3 fill`_exp ]is left zero`-padding of exponent in exponential
|
||||
notation&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatDoubleFix`(double`,int`,int`):%- [_^String^ String]_[* FormatDoubleFix]([@(0.0.255) d
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatDoubleFix`(double`,int`,int`): [_^String^ String]_[* FormatDoubleFix]([@(0.0.255) d
|
||||
ouble]_[*@3 d], [@(0.0.255) int]_[*@3 digits], [@(0.0.255) int]_[*@3 flags]_`=_[@3 0])&]
|
||||
[s2; Formats a floating point number [%-*@3 d] in ordinary decimal
|
||||
[s2;%% Formats a floating point number [%-*@3 d] in ordinary decimal
|
||||
notation (whole part, comma, decimal part). Then number of [%-*@3 digits]
|
||||
can be interpreted either as the absolute number of decimal digits
|
||||
(the default mode) or the relative number of significant digits
|
||||
excluding leading zeros. Decimal point is always output as a
|
||||
period independent on language settings. [%-*@3 flags] can be a
|
||||
binary combination ([@(0.0.255) `|]) of&]
|
||||
[s0; &]
|
||||
[ {{2098:7902<288;h1; [s0; FD`_SIGN]
|
||||
:: [s0; [/ always prepend sign (`+10)]]
|
||||
:: [s0; FD`_REL]
|
||||
:: [s0; [/ relative decimal places (valid digits)]]
|
||||
:: [s0; FD`_ZERO]
|
||||
:: [s0; [/ keep trailing zeros (1.25000)]]}}&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatDoubleExp`(double`,int`,int`,int`):%- [_^String^ String]_[* FormatDoubleExp]([@(0.0.255) d
|
||||
[s0;%% &]
|
||||
[ {{2098:7902<288;h1; [s0;%% FD`_SIGN]
|
||||
:: [s0;%% [/ always prepend sign (`+10)]]
|
||||
:: [s0;%% FD`_REL]
|
||||
:: [s0;%% [/ relative decimal places (valid digits)]]
|
||||
:: [s0;%% FD`_ZERO]
|
||||
:: [s0;%% [/ keep trailing zeros (1.25000)]]}}&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatDoubleExp`(double`,int`,int`,int`): [_^String^ String]_[* FormatDoubleExp]([@(0.0.255) d
|
||||
ouble]_[*@3 d], [@(0.0.255) int]_[*@3 digits], [@(0.0.255) int]_[*@3 flags]_`=_[@3 0],
|
||||
[@(0.0.255) int]_[*@3 fill`_exp]_`=_[@3 0])&]
|
||||
[s2; Formats a floating point number [%-*@3 d] in scientific / exponential
|
||||
[s2;%% Formats a floating point number [%-*@3 d] in scientific / exponential
|
||||
notation (sign, single digit, period, decimal part, `"e`" decimal
|
||||
exponent) with given number of [%-*@3 digits]. [%-*@3 flags] can
|
||||
be a binary combination ([@(0.0.255) `|]) of&]
|
||||
[s2; &]
|
||||
[ {{2098:7902<288;h1; [s0; FD`_SIGN]
|
||||
:: [s0; [/ always prepend sign (`+10)]]
|
||||
:: [s0; FD`_SIGN`_EXP]
|
||||
:: [s0; [/ always prepend sign to exponent (1e`+2)]]
|
||||
:: [s0; FD`_CAP`_E]
|
||||
:: [s0; [/ capital E for exponent (1E10)]]
|
||||
:: [s0; FD`_ZERO]
|
||||
:: [s0; [/ keep trailing zeros (1.25000)]]}}&]
|
||||
[s2; &]
|
||||
[s2; [*@3 fill`_exp ]is left zero`-padding of exponent in exponential
|
||||
[s2;%% &]
|
||||
[ {{2098:7902<288;h1; [s0;%% FD`_SIGN]
|
||||
:: [s0;%% [/ always prepend sign (`+10)]]
|
||||
:: [s0;%% FD`_SIGN`_EXP]
|
||||
:: [s0;%% [/ always prepend sign to exponent (1e`+2)]]
|
||||
:: [s0;%% FD`_CAP`_E]
|
||||
:: [s0;%% [/ capital E for exponent (1E10)]]
|
||||
:: [s0;%% FD`_ZERO]
|
||||
:: [s0;%% [/ keep trailing zeros (1.25000)]]}}&]
|
||||
[s2;%% &]
|
||||
[s2;%% [*@3 fill`_exp ]is left zero`-padding of exponent in exponential
|
||||
notation&]
|
||||
[s3; &]
|
||||
[s4;%- &]
|
||||
[s5;:FormatIntBase`(int`,int`,int`,char`,int`):%- [_^String^ String]_[* FormatIntBase]([@(0.0.255) i
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:FormatIntBase`(int`,int`,int`,char`,int`): [_^String^ String]_[* FormatIntBase]([@(0.0.255) i
|
||||
nt]_[*@3 i], [@(0.0.255) int]_[*@3 base], [@(0.0.255) int]_[*@3 width]_`=_[@3 0],
|
||||
[@(0.0.255) char]_[*@3 lpad]_`=_`'_`', [@(0.0.255) int]_[*@3 sign]_`=_[@3 0])&]
|
||||
[s0; ]]
|
||||
[s0;%% ]]
|
||||
|
|
@ -10,45 +10,49 @@ topic "Conversion between strings and numbers";
|
|||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[{_}
|
||||
[ {{10000@(113.42.0) [s0;%% [*@7;4 Conversion between strings and numbers]]}}&]
|
||||
[s9; Sometimes you need to convert numbers to strings and vice vers.
|
||||
U`+`+ provides several functions to help you efficiency deal
|
||||
with that task. In this reference topic, we only mention the
|
||||
most important ones.&]
|
||||
[s3; &]
|
||||
[s0; If you are looking for more powerfull convertion tools. You
|
||||
can see at [^topic`:`/`/Core`/src`/Format`$en`-us`#Formatting`:`:struct^ Format]
|
||||
and [^topic`:`/`/Core`/src`/Convert`$en`-us`#Convert`:`:class^ Convert]
|
||||
class documentation.&]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* String to number converting functions]]}}&]
|
||||
[ {{10000@(113.42.0) [s0;%% [*@7;4 Numeric Conversions]]}}&]
|
||||
[s3; &]
|
||||
[s5;:Upp`:`:StrInt`(const char`*`): [@(0.0.255) int]_[* StrInt]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har`*]_[*@3 s])&]
|
||||
[s2; Converts string to integer.&]
|
||||
[s7;%% [%-*C@3 s]-|String&]
|
||||
[s7;%% [*/ Return value]-|String converted to integer.&]
|
||||
[s3; &]
|
||||
[s0; &]
|
||||
[ {{10000F(128)G(128)@1 [s0;%% [* Number to string converting functions]]}}&]
|
||||
[s0; &]
|
||||
[s5;:Upp`:`:IntStr`(int`): [_^Upp`:`:String^ String]_[* IntStr]([@(0.0.255) int]_[*@3 i])&]
|
||||
[s2; Converts integer to string.&]
|
||||
[s7;%% [%-*C@3 i]-|Integer.&]
|
||||
[s7;%% [*/ Return value]-|Integer converted to string.&]
|
||||
[s2; Converts string [*@3 s] to integer. Returns Null if there is no
|
||||
number in [*@3 s].&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:IntStr64`(Upp`:`:int64`): [_^Upp`:`:String^ String]_[* IntStr64]([_^Upp`:`:int64^ i
|
||||
nt64]_[*@3 i])&]
|
||||
[s2; Converts 64 bits integer to string.&]
|
||||
[s7;%% [%-*C@3 i]-|Integer.&]
|
||||
[s7;%% [*/ Return value]-|Integer converted to string.&]
|
||||
[s5;:Upp`:`:IntStr`(int`): [_^Upp`:`:String^ String]_[* IntStr]([@(0.0.255) int]_[*@3 i])&]
|
||||
[s2; Converts integer [*@3 i] to String. If [*@3 i] is Null, returns
|
||||
empty String.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:StrDbl`(const char`*`): [@(0.0.255) double]_[* StrDbl]([@(0.0.255) const]_[@(0.0.255) c
|
||||
har`*]_[*@3 s])&]
|
||||
[s2; Converts string [*@3 s] to double. Returns Null if there is no
|
||||
number in [*@3 s].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:DblStr`(double`): [_^Upp`:`:String^ String]_[* DblStr]([@(0.0.255) double]_[*@3 d
|
||||
])&]
|
||||
[s2; Converts double precision number to string.&]
|
||||
[s7;%% [%-*C@3 i]-|Integer.&]
|
||||
[s7;%% [*/ Return value]-|Double converted to string.&]
|
||||
[s2; Converts double [*@3 d] to String. If [*@3 d] is Null, returns empty
|
||||
String.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:StrInt64`(Upp`:`:int64`): [_^Upp`:`:String^ String]_[* StrInt64]([_^Upp`:`:int64^ i
|
||||
nt64]_[*@3 i])&]
|
||||
[s2;%% [%- Converts string ][%-*@3 s][%- to 64`-bit integer. Returns Null
|
||||
if there is no number in ][%-*@3 s][%- .].&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:IntStr64`(Upp`:`:int64`): [_^Upp`:`:String^ String]_[* IntStr64]([_^Upp`:`:int64^ i
|
||||
nt64]_[*@3 i])&]
|
||||
[s2; Converts 64`-bit integer [*@3 i] to String. If [*@3 i] is Null,
|
||||
returns empty String.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:IntDbl`(int`): [@(0.0.255) double]_[* IntDbl]([@(0.0.255) int]_[*@3 i])&]
|
||||
[s2;%% Converts integer to double. If [%-*@3 i] is Null, returns (double)Null,
|
||||
otherwise performs simple cast.&]
|
||||
[s3;%% &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:DblInt`(double`): [@(0.0.255) int]_[* DblInt]([@(0.0.255) double]_[*@3 d])&]
|
||||
[s2;%% Converts double to integer. If [%-*@3 d] is Null, returns (int)Null,
|
||||
otherwise performs simple cast.&]
|
||||
[s0; ]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue