Real Numbers representation in Tcl language
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 ... Thank you, MEM
On Tuesday, April 11, 2006 @ 8:04 PM, Maura E. 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 ...
Thank you, MEM Well, I'm just waging here, but in order to store an ordinate of 10, the computer would only need to have 4 bits assigned to store said ordinate. 10 would be 1010. I don't know anything about TCL language, but, if you can't store a number of that size, it's not a hardware issue, certainly not on a 32 bit machine. But it's pretty safe to say that the maximum ordinate is indeed dependent on machine architecture. I mean, if you have 64 bits available instead of 32, you can store both more precision and more order of magnitude than on a 32 bit machine. Now, whether the particular language you are coding in is aware of the fact that it has those extra bits to work with is a totally different matter.
Greg Wallace P. S.: Fellow list members more knowledgeable about hardware, if I'm off base here, then you have permission to shoot me.
The strange behaviour undelying this issue is that every parameer is declared Real in C language. Tcl is used to build the GUI that allows the program users to alter the default values, if desired, in a friendly way. For some reson to me unknown (I've never used Tcl before) Tcl regards the Real numbers as Integers.... This is just my diagnosis .. I maight be wrong ... I'll probably post a more detailed question when I have a chance to install and compile the code in question on my laptop. Thank you for all your help and suggestions. Maura On Wed, 12 Apr 2006, Greg Wallace wrote:
On Tuesday, April 11, 2006 @ 8:04 PM, Maura E. 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 ...
Thank you, MEM Well, I'm just waging here, but in order to store an ordinate of 10, the computer would only need to have 4 bits assigned to store said ordinate. 10 would be 1010. I don't know anything about TCL language, but, if you can't store a number of that size, it's not a hardware issue, certainly not on a 32 bit machine. But it's pretty safe to say that the maximum ordinate is indeed dependent on machine architecture. I mean, if you have 64 bits available instead of 32, you can store both more precision and more order of magnitude than on a 32 bit machine. Now, whether the particular language you are coding in is aware of the fact that it has those extra bits to work with is a totally different matter.
Greg Wallace
P. S.: Fellow list members more knowledgeable about hardware, if I'm off base here, then you have permission to shoot me.
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Wednesday 2006-04-12 at 04:08 -0500, Maura Edeweiss Monville wrote:
The strange behaviour undelying this issue is that every parameer is declared Real in C language. Tcl is used to build the GUI that allows the program users to alter the default values, if desired, in a friendly way. For some reson to me unknown (I've never used Tcl before) Tcl regards the Real numbers as Integers.... This is just my diagnosis .. I maight be wrong ...
In general, a compiler may use any size of "real" it wants - I mean the compiler designer may, not you. But, as procesors nowdays include real math operations (the old coprocesor of the intel x86 series), they use one or several of the "real" types the procesor handles. As I haven't done much programming in Linux, I don't know what types are available, but 32 bits seems a smallish real to me. - -- Cheers, Carlos Robinson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) Comment: Made with pgp4pine 1.76 iD8DBQFEPNNltTMYHG2NR9URAn2jAJ9Agos4HZXE5sasbd4GEiruhmSWegCcC/6l owqWRPmblqX/fRX+Pej93JY= =sQGA -----END PGP SIGNATURE-----
On Wednesday 12 April 2006 11:08, Maura Edeweiss Monville wrote:
The strange behaviour undelying this issue is that every parameer is declared Real in C language. Tcl is used to build the GUI that allows the program users to alter the default values, if desired, in a friendly way. For some reson to me unknown (I've never used Tcl before) Tcl regards the Real numbers as Integers.... This is just my diagnosis .. I maight be wrong ...
Who declares them as real in C? Tcl or some other app? If you enter a value as 1 (no decimal) it is assumed to be an integer. But if you later enter 1.0, I think it changes to a double. At least from a Tcl script. -- Roger Oberholtzer OPQ Systems AB
On Wednesday 12 April 2006 07:43, Greg Wallace wrote:
On Tuesday, April 11, 2006 @ 8:04 PM, Maura E. 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 ...
Thank you, MEM
Well, I'm just waging here, but in order to store an ordinate of 10, the computer would only need to have 4 bits assigned to store said ordinate. 10 would be 1010. I don't know anything about TCL language, but, if you can't store a number of that size, it's not a hardware issue, certainly not on a 32 bit machine. But it's pretty safe to say that the maximum ordinate is indeed dependent on machine architecture. I mean, if you have 64 bits available instead of 32, you can store both more precision and more order of magnitude than on a 32 bit machine. Now, whether the particular language you are coding in is aware of the fact that it has those extra bits to work with is a totally different matter.
Tcl simply uses the underlying machine's representation. No funny stuff. An integer is 32 bits. -- Roger Oberholtzer OPQ Systems AB
On Wednesday 12 April 2006 10:53 am, Roger Oberholtzer wrote:
Tcl simply uses the underlying machine's representation. No funny stuff. An integer is 32 bits. But, Maura is talking floating point, and double precision floating point numbers in C are 64-bit on 32-bit and 64-bit platforms.
int is always 32-bit on 32-bit and 64-bit systems, and long is 32-bits on
32-bit systems and 64-bits on 64-bit systems.
--
Jerry Feldman
On Wed, 2006-04-12 at 14:54 -0400, Jerry Feldman wrote:
On Wednesday 12 April 2006 10:53 am, Roger Oberholtzer wrote:
Tcl simply uses the underlying machine's representation. No funny stuff. An integer is 32 bits. But, Maura is talking floating point, and double precision floating point numbers in C are 64-bit on 32-bit and 64-bit platforms.
Tcl has only one floating point storage format. It is the C double. So, whatever your C compiler does to store a double is what you will get in Tcl. Nothing more or less. When converting doubles to strings, tcl by default will provide 12 decimal places. This can be changed via the tcl_precision setting.
int is always 32-bit on 32-bit and 64-bit systems, and long is 32-bits on 32-bit systems and 64-bits on 64-bit systems.
AFAIK, Tcl only runs on 32-bit or 64-bit machines. And, on these, Tcl acts as stared above for floating point representation. Tcl does not have a concept of 'type' in the script environment. Internally, it determines the best binary storage for a value based on how it parses variable assignment.
-- Jerry Feldman
Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
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.
--
Jerry Feldman
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
Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
-- Roger Oberholtzer OPQ Systems AB
participants (5)
-
Carlos E. R.
-
Greg Wallace
-
Jerry Feldman
-
Maura Edeweiss Monville
-
Roger Oberholtzer