aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/eval.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/eval.txt')
-rw-r--r--runtime/doc/eval.txt44
1 files changed, 25 insertions, 19 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index e295772693..3472294483 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -65,14 +65,16 @@ the Number. Examples:
Number 0 --> String "0" ~
Number -1 --> String "-1" ~
*octal*
-Conversion from a String to a Number is done by converting the first digits
-to a number. Hexadecimal "0xf9" and Octal "017" numbers are recognized. If
-the String doesn't start with digits, the result is zero. Examples:
+Conversion from a String to a Number is done by converting the first digits to
+a number. Hexadecimal "0xf9", Octal "017", and Binary "0b10" numbers are
+recognized. If the String doesn't start with digits, the result is zero.
+Examples:
String "456" --> Number 456 ~
String "6bar" --> Number 6 ~
String "foo" --> Number 0 ~
String "0xf1" --> Number 241 ~
String "0100" --> Number 64 ~
+ String "0b101" --> Number 5 ~
String "-8" --> Number -8 ~
String "+8" --> Number 0 ~
@@ -4912,6 +4914,9 @@ printf({fmt}, {expr1} ...) *printf()*
%c single byte
%d decimal number
%5d decimal number padded with spaces to 5 characters
+ %b binary number
+ %08b binary number padded with zeros to at least 8 characters
+ %B binary number using upper case letters
%x hex number
%04x hex number padded with zeros to at least 4 characters
%X hex number using upper case letters
@@ -4998,20 +5003,19 @@ printf({fmt}, {expr1} ...) *printf()*
The conversion specifiers and their meanings are:
- *printf-d* *printf-o* *printf-x* *printf-X*
- doxX The Number argument is converted to signed decimal
- (d), unsigned octal (o), or unsigned hexadecimal (x
- and X) notation. The letters "abcdef" are used for
- x conversions; the letters "ABCDEF" are used for X
- conversions.
- The precision, if any, gives the minimum number of
- digits that must appear; if the converted value
- requires fewer digits, it is padded on the left with
- zeros.
- In no case does a non-existent or small field width
- cause truncation of a numeric field; if the result of
- a conversion is wider than the field width, the field
- is expanded to contain the conversion result.
+ *printf-d* *printf-b* *printf-B* *printf-o* *printf-x* *printf-X*
+ dbBoxX The Number argument is converted to signed decimal (d),
+ unsigned binary (b and B), unsigned octal (o), or
+ unsigned hexadecimal (x and X) notation. The letters
+ "abcdef" are used for x conversions; the letters
+ "ABCDEF" are used for X conversions. The precision, if
+ any, gives the minimum number of digits that must
+ appear; if the converted value requires fewer digits, it
+ is padded on the left with zeros. In no case does a
+ non-existent or small field width cause truncation of a
+ numeric field; if the result of a conversion is wider
+ than the field width, the field is expanded to contain
+ the conversion result.
*printf-c*
c The Number argument is converted to a byte, and the
@@ -6127,12 +6131,14 @@ str2float( {expr}) *str2float()*
str2nr( {expr} [, {base}]) *str2nr()*
Convert string {expr} to a number.
- {base} is the conversion base, it can be 8, 10 or 16.
+ {base} is the conversion base, it can be 2, 8, 10 or 16.
When {base} is omitted base 10 is used. This also means that
a leading zero doesn't cause octal conversion to be used, as
with the default String to Number conversion.
When {base} is 16 a leading "0x" or "0X" is ignored. With a
- different base the result will be zero.
+ different base the result will be zero. Similarly, when {base}
+ is 8 a leading "0" is ignored, and when {base} is 2 a leading
+ "0b" or "0B" is ignored.
Text after the number is silently ignored.