When turning the motors, how precise is the speed parameter? I am programming in the NXC language (standard firmware) and wishing to know how many decimal points will be taken, if any, and whether the input speed will be truncated, rounded or neither.

1 Answer 1


From the page you linked to we can see that the NXC OnFwd method has the following parameters:

void OnFwd (byte outputs, char pwr)

The power or speed parameter is listed as a char type, and looking around elsewhere on the site we find the definition of the char to be:

In NXC the char type is a signed 8-bit value. This type can store values from SCHAR_MIN to SCHAR_MAX.

This means it can hold an integer value between -128 and 127.

It cannot take any decimal values.

I assume that a char was used over an int as they only need to support values between -100 and 100 in this method.

  • 1
    Thanks, for some reason I didn't connect value to integral value, but looking at the int and float description it's quite obvious! When I use a decimal value as a parameter there is no compiler or runtime error; I believe C would just truncate a floating point number to an integer, ao I presume it would be the same in NXT for float to char?
    – lpd
    Mar 15, 2012 at 10:21
  • I guess so - I can't say I've tried, but yes, there's possibly some implicit conversions going on. Mar 15, 2012 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.