Floating point arithmetic is expensive. brickOS has built in support for it,
so just use float
as you normally would, but keep in mind that floating
point math will often take 50 percent longer than integer math that would achieve the
same results.
Don't be afraid of rough numbers. If you've attached a rotation sensor to your wheels and want to calculate velocity, then use integer math and forget about precision unless you absolutely need it. If you want to do a fine-grained division, or multiply by a fraction, then multiply the number first and then divide.
random() and srandom(int x) are available in brickOS. To use them, just call srandom(int x) at some point during your program startup. x is a "seed", which allows you to get the same sequence of numbers if you so desire (by passing the same seed) or to generate more truly "random" numbers by feeding in, for example, LIGHT_1. Be aware: unlike the "standard" implementation of these two functions, there is no "default" seed, so if you don't call srandom() at least once, random() will return the same number over and over again.
When no programs are running, press the view
button on your RCX to
get a list of information. Each time you press view, you will get something. This
is what you will see
free
xxxx
- the amount of free space on your brick (decimal)
xxxx
- the amount of free space on your brick (hex)
batt
xxxx
- the battery life left (millivolts)
addr
xxxx
- the LNP address of your brick
ints and such may be slightly smaller than you are used to in "real" programming. In specific, an int is only 16 bits long, so it will overflow at around 32K if signed and around 64K if unsigned.
There is a newsgroup dedicated to discussion of brickOS. It is available at
news://news.lugnet.com/lugnet.robotics.rcx.legos