Rnum = num;
Rnum = (float) num;
Is it ;possible to do the same in Tcl language ?
I have an integer value but it's too big to e represented as an
integer.
However, I've just found out Tcl has no problem at representing the
float
counterpart.
Is it possible to convert integers into real numbers with Tcl ?
How ?
Thank you so much,
Maura
expr {wide($num)} converts to a very large integer
expr{double($num)} converts to a double-precision floating-point number
Regards,
Arjen
I think I now understand what the original poster wants, and I'll
post on that later in the day. Notice, though, Arjen, that
% expr wide(111111111111111111111111111111111111)
integer value too large to represent
% expr double(11111111111111111111111111111111111)
integer value too large to represent
How about
set i 111111111111111111111111111111111111
set i $i.0
expr {$i}
Cheers
Ulrich
isn't there another possibility?
Martin
But also notice:
% expr wide(111111111111111111111111111111111111)
-2663765922256490041
% expr double(11111111111111111111111111111111111)
1.111111111111111e+34
% expr entier(11111111111111111111111111111111111)
11111111111111111111111111111111111
% info patch
8.5a4
Donal.
the examples of yours don't work with my tclkit(sh) 8.5a4.
There is always the error message "integer value too large to
represent".
Do I miss a thing?
# Accomodate integer overflows.
if {![string match *.* $num]} {
append num .
}
set intfmt "%8.1f"
set floatfmt "%8.4f"
set scienfmt "%8.2e"
...
Try this, and report whether it achieves what you're after.
With that in hand, we can straighten out your other questions
in relative leisure.
I can't remember when exactly the bignum support went in, so perhaps you
have an 8.5a4 pre-TIP 237.
On this subject, I notice some (all?) Scheme implementation allow you to
require individual SRFIs. Perhaps we could do the same with TIPs?
package require tip-237 1.0
or something similar. Or we could just live with the fact that 8.5 is in
development and so the precise feature set available in any particular
8.5 tclsh is variable.
-- Neil
Well, it works for me with the 8.5a4 release revisions. Time to upgrade!
Donal.