Displaying integers on the display

Hi, I’m trying to display an integer i’ve created called shootval, like so:

while(1)
{
    Brain.Screen.printAt( 10,  20, "value: %f"  , shootval);
}

However, when I try doing this, it displays
value: 4294967295.4294967295

Could someone tell me the correct format of displaying integers on the screen? Thanks.

You want to use %d, not %f.

http://www.cplusplus.com/reference/cstdio/printf/

If you want to display decimals but round to the nearest hundredth or tenth then it would be:

Brain.Screen.printAt( 10, 20, “value: %.2f” , shootval);

Brain.Screen.printAt( 10, 20, “value: %.1f” , shootval);

Our students have noticed that too. Much of the VCS API Reference has %f in the documentation, like the following link:. https://help.vexcodingstudio.com/#cpp/namespacevex/classvex_1_1line/value

They have been fixing it switching to %d, instead.

yea, I need to remind them again to fix those code snippets.
any method that returns int32_t should use %d and not %f. Only methods returning double should be using %f

2 Likes