-- re-sending as I received delivery failure. Apologies for multiple
responses. --
You need to typecast the variable in expression for precision.
[dpanwar@UnixServer1 NS]$ ns
% set a 18
18
% set b 1000
1000
% set x [expr double($a)/$b]
0.017999
To truncate the large float values, you may need to set the*
tcl_precision* variable
and get the desired result.
% set tcl_precision 10
10
% set x [expr double($a)/$b]
0.018
With best regards,
Deepak Panwar
--
*Effort is important, but knowing where to make an effort makes all the
difference!*
On Wed, Feb 19, 2014 at 11:14 AM, Deepak Panwar
deepakdeeppan...@gmail.comwrote:
You need to typecast the variable in expression for precision.
[dpanwar@UnixServer1 NS]$ ns
% set a 18
18
% set b 1000
1000
% set x [expr double($a)/$b]
0.017999
To truncate the large float values, you may need to set the*
tcl_precision* variable and get the desired result.
% set tcl_precision 10
10
% set x [expr double($a)/$b]
0.018
With best regards,
Deepak Panwar
--
*Effort is important, but knowing where to make an effort makes all the
difference!*
On Wed, Feb 19, 2014 at 6:30 AM, ns-users-requ...@isi.edu wrote:
Send Ns-users mailing list submissions to
ns-users@isi.edu
To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.isi.edu/mailman/listinfo/ns-users
or, via email, send a message with subject or body 'help' to
ns-users-requ...@isi.edu
You can reach the person managing the list at
ns-users-ow...@isi.edu
When replying, please edit your Subject line so it is more specific
than Re: Contents of Ns-users digest...
Today's Topics:
1. arithmatic in TCL for ns2 (Muhammad Imran KHAN)
2. Re: running configuration..Installation of tclcl seems
incomplete or can't be found automatically. (knudfl)
-- Forwarded message --
From: Muhammad Imran KHAN exceptional_attract...@yahoo.com
To: ns-users ns-users@isi.edu
Cc:
Date: Tue, 18 Feb 2014 09:25:32 + (GMT)
Subject: [ns] arithmatic in TCL for ns2
Hi ,
I have some problem regarding arithmatic expressions.
I have prepared a file .tcl and then I include it in main ns simulator
file.
For example,
set x [expr $a / $b]
ie.
x = 18 /1000 , it gives me zero value rather than 0.018. Why ?
what should I do Please? to get exact 0.018 .
Thanks you so much for your kind help.
Best Regards,
Imran Khan