aboutsummaryrefslogtreecommitdiff
path: root/jim_tcl.txt
diff options
context:
space:
mode:
authorVadim Zborovskii <vadim_z@triniti.ru>2013-08-11 09:55:54 +1000
committerSteve Bennett <steveb@workware.net.au>2013-08-19 21:15:55 +1000
commit37df8a6098f0b7876fade21fccb08023b2f978d3 (patch)
tree96ca9113b8be01a8acece8e43ba36f9989fbffdd /jim_tcl.txt
parentb4cf237e6535cd1e33a83a0635896956853fd32b (diff)
downloadjimtcl-37df8a6098f0b7876fade21fccb08023b2f978d3.zip
jimtcl-37df8a6098f0b7876fade21fccb08023b2f978d3.tar.gz
jimtcl-37df8a6098f0b7876fade21fccb08023b2f978d3.tar.bz2
Add pack/unpack support for floating point
Diffstat (limited to 'jim_tcl.txt')
-rw-r--r--jim_tcl.txt21
1 files changed, 12 insertions, 9 deletions
diff --git a/jim_tcl.txt b/jim_tcl.txt
index 07e5c12..bb197a7 100644
--- a/jim_tcl.txt
+++ b/jim_tcl.txt
@@ -4662,21 +4662,22 @@ pack: pack, unpack
~~~~~~~~~~~~~~~~~~
The optional 'pack' extension provides commands to encode and decode binary strings.
-+*pack* 'varName value' *-intle|-intbe|-str* 'bitwidth ?bitoffset?'+::
++*pack* 'varName value' *-intle|-intbe|-floatle|-floatbe|-str* 'bitwidth ?bitoffset?'+::
Packs the binary representation of +'value'+ into the variable
+'varName'+. The value is packed according to the given type
- (integer/string, big-endian/little-endian), width and bit offset.
+ (integer/floating point/string, big-endian/little-endian), width and bit offset.
The variable is created if necessary (like `append`).
Ihe variable is expanded if necessary.
-+*unpack* 'binvalue' *-intbe|-intle|-uintbe|-uintle|-str* 'bitpos bitwidth'+::
++*unpack* 'binvalue' *-intbe|-intle|-uintbe|-uintle|-floatbe|-floatle|-str* 'bitpos bitwidth'+::
Unpacks bits from +'binvalue'+ at bit position +'bitpos'+ and with +'bitwidth'+.
- Interprets the value according to the type (integer/string, big-endian/little-endian
+ Interprets the value according to the type (integer/floating point/string, big-endian/little-endian
and signed/unsigned) and returns it. For integer types, +'bitwidth'+
- may be up to the size of a Jim Tcl integer (typically 64 bits). For the string type,
- both the width and the offset must be on a byte boundary (multiple of 8). Attempting to
- access outside the length of the value will return 0 for integer types or the empty string
- for the string type.
+ may be up to the size of a Jim Tcl integer (typically 64 bits). For floating point types,
+ +'bitwidth'+ may be 32 bits (for single precision numbers) or 64 bits (for double precision).
+ For the string type, both the width and the offset must be on a byte boundary (multiple of 8). Attempting to
+ access outside the length of the value will return 0 for integer types, 0.0 for floating point types
+ or the empty string for the string type.
binary
~~~~~~
@@ -4685,7 +4686,9 @@ commands based on the low-level `pack` and `unpack` commands.
See the Tcl documentation at: http://www.tcl.tk/man/tcl8.5/TclCmd/binary.htm
-Note that packing and unpacking of floating point values is not supported.
+Packing and unpacking of floating point values is supported as an experimental feature.
+Note that 'binary format' with f/r/R specifiers (single-precision float) uses the value of Infinity
+ in case of overflow.
oo: class, super
~~~~~~~~~~~~~~~~