how to convert the unit "double" to "ns3::Time"

491 views
Skip to first unread message

KH Chua

unread,
Feb 24, 2014, 6:03:12 AM2/24/14
to ns-3-...@googlegroups.com
Is there a function to convert the unit "double" to "ns3::Time"?

Konstantinos

unread,
Feb 24, 2014, 6:18:56 AM2/24/14
to ns-3-...@googlegroups.com
It depends what does this double stand for. 

Is it seconds? You can call Seconds(<value>). 
See for more related functions here http://www.nsnam.org/doxygen/classns3_1_1_time.html

KH Chua

unread,
Feb 24, 2014, 6:49:29 AM2/24/14
to ns-3-...@googlegroups.com
I want to convert it to miliseconds. From that link,I only see the following two that convert to miliseconds. But it doesn't have function to convert from double. Does it mean we cannot convert double to miliseconds?

Time MilliSeconds (uint64_t ms)
 create ns3::Time instances in units of milliseconds. More...
 
Time MilliSeconds (int64x64_t ms)

KH Chua

unread,
Feb 24, 2014, 6:52:23 AM2/24/14
to ns-3-...@googlegroups.com
Thanks. I wanted to convert double to "miliseconds". I only see the following two functions in that link but both of them are not converting from double:

Time MilliSeconds (uint64_t ms)
 create ns3::Time instances in units of milliseconds. More...
 
Time MilliSeconds (int64x64_t ms)

But I think I can divide my answer by 1000 first before converting to seconds

On Monday, February 24, 2014 7:18:56 PM UTC+8, Konstantinos wrote:

Konstantinos

unread,
Feb 24, 2014, 7:27:28 AM2/24/14
to ns-3-...@googlegroups.com
Yes, if you have miliseconds in 'double', then you can divide it by 1000 to have it in seconds and use the Seconds.

Or you can do the following

static Time FromDouble (double value, enum Unit timeUnit)

and use the double you have and use the unit MS, which is actually what is called by the Seconds() method.

KH Chua

unread,
Feb 24, 2014, 7:30:19 AM2/24/14
to ns-3-...@googlegroups.com
Thanks a lot

I will try it out
Reply all
Reply to author
Forward
0 new messages