Ask Your Question
0

What is the difference between the usage of %i, %d,%f in ROS_INFO("")?

asked 2019-07-05 00:08:56 -0500

Dickson gravatar image

I see a lot of usage of like

ROS_INFO("%d")

ROS_INFO("%i")

ROS_INFO("%f")

used, is there a difference in the usage of them? If so, what are the differences. Is there like a webpage where this has been explained?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-07-05 00:54:42 -0500

updated 2019-07-05 00:56:11 -0500

ROS_INFO and other ROS log functions follow the same format as the standard C printf function. You can find more information here http://wiki.ros.org/rosconsole and http://www.cplusplus.com/reference/cs...

The ones you mention:

int decimal_integer_value = 5;
float float_pont_value = 10.0f;
ROS_INFO("%d", decimal_integer_value);
ROS_INFO("%i", decimal_integer_value);
ROS_INFO("%f", float_point_value);

Would output:

 5
 5
 10.0

%d and %i are equivalent and use to print decimal integer values, %f is used to print floating point numbers"

edit flag offensive delete link more

Comments

Thank you very much (:

Dickson gravatar imageDickson ( 2019-07-08 03:52:34 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-07-05 00:08:56 -0500

Seen: 57 times

Last updated: Jul 05