Mailinglist Archive: opensuse (3337 mails)

< Previous Next >
Re: [SLE] Real Numbers representation in Tcl language
  • From: Roger Oberholtzer <roger@xxxxxx>
  • Date: Wed, 12 Apr 2006 16:49:25 +0200
  • Message-id: <200604121649.26021.roger@xxxxxx>
On Wednesday 12 April 2006 15:29, Jerry Feldman wrote:
> On Tuesday 11 April 2006 9:04 pm, Maura Edeweiss Monville wrote:
> > Is it possible that on a 32-bit machine the maximum value for a Real
> > number in Tcl language is 10^10 ?
> >
> > Instinctively I'd saythe number of bits assigned to the representation of
> > a Real number is independent on the machine h/w architecture ... but I'm
> > not familiar with Tcl and may be mistaken ...
> AFAIK, Tcl does all of its computations as doubles, and a double on a
> 32-bit or 64-bit system is 64-bits. Additionally, AFAIK, Tcl stores its
> variables as strings.

Tcl variables are 'dual ported' So, a double is first stored as it was given.
When accessed, if the destination is different from what was originally
given, it is converted. This may sound strange, but it means that a double
stored as a string and accessed as a string will be the same. If it is stored
as a string but needed as a double (from C code ot to be used in a
calculation) then it is converted to a double. The reason is speed. No
unneeded conversions are performed. A Tcl variable stored as a double from C
and accessed as a double from C never gets sonverted to a string.

The double format is whatever is native to your platform. There is also a
64-bit integer available on all platforms.

> --
> Jerry Feldman <gaf@xxxxxxx>
> Boston Linux and Unix user group
> PGP key id:C5061EA9
> PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9

Roger Oberholtzer
OPQ Systems AB

< Previous Next >