LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
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 '12 at 10:21
I guess so - I can't say I've tried, but yes, there's possibly some implicit conversions going on. – Zhaph - Ben Duguid Mar 15 '12 at 10:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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