data type in ns3

58 views
Skip to first unread message

Nitya Kulkarni

unread,
Oct 16, 2014, 10:46:13 AM10/16/14
to ns-3-...@googlegroups.com
Hello!!
I wanted to know what data type to use to define a metric variable in class which will store values in decimal form. I have seen in many ns3 files double data type is not used. Does uint32_t can store decimal values as well in ns3 ?

Thank you

Konstantinos

unread,
Oct 16, 2014, 11:20:56 AM10/16/14
to ns-3-...@googlegroups.com
Hi Nitya,

NS-3 does not do any magic converting integers to floats. It follows the rules of C++. The fact that you see uintXX_t used that often in NS-3 is that only an integer is required, not decimal. 

uintXX_t can not store decimal form. It is an unsigned integer.
You can use double or floats or any other data type for local variables. 
However, if you want to transmit this value (e.g. send it with a packet) you need to re-format it to unsigned integer. 
Reply all
Reply to author
Forward
0 new messages