|
||||||
ERS-110, 111 |
ERS-210[A], 220[A] |
Programming AIBO with: YART, RCodePlus OpenR SDK
|
ERS-311[B], 312[B], 31L |
ERS7 |
||
|
Home
Movies (all) |
PDAs: CLIE
( Panel
Zipit )
Lesser Robots: Pleo ( RoboSapien ICybie ) Game Hacks: Nintendo Wii Nintendo DS ( PSP ) |
Email: aibopet@aibohack.com | ||||
RCodePlus Double Precision Floating Point |
LOCAL fpu_array 25
AP_DIM fpu_array ## // ## = number of FPU registers times 4
SET AP_fpu fpu_array // use this array from now on
All DBL_ operations use indices into this array (that are first multiplied by 8 bytes). So your indices you use start with 0 and go up by 1.
// float_value = int_part . fract_part
if (int_part > 0)
{
// positive
assert(fract_part >= 0 && fract_part < 10000);
float_value = int_part + fract_part / 10000;
}
else if (int_part < 0)
{
// negative, fract_part is not signed
assert(fract_part >= 0 && fract_part < 10000);
float_value = int_part - fract_part / 10000;
}
else
{
// int_part = 0, in this case, fract_part is signed
assert(fract_part > -10000 && fract_part < 10000);
float_value = int_part + fract_part / 10000;
}
Try to keep values in the FPU registers for as long as you can, and only convert to RCODE variables when you need to.
DBL_SET index int_part fract_part // fpu[index] = int_part . fract_part
DBL_SET index index2 // fpu[index] = fpu
DBL_GET index variable_for_int_part variable_for_fract_part
For example:
DBL_SET 1 10 5 // fpu[0] = 10.5
DBL_GET 1 a b // a = 10, b = 5
DBL_ADD index0 index1 index2 // fpu[index0] = fpu[index1] + fpu[index2]
DBL_ADD index0 index1 int_part fract_part // fpu[index0] = fpu[index1] + int_part . fract_part
For example:
DBL_ADD 9 9 1 0 // fpu[9] += 1.0
All the binary operators have the same format:
DBL_SIN index0 index1 // fpu[index0] = sin ( fpu[index1] )
DBL_SIN index0 int_part fract_part // fpu[index0] = sin ( int_part . fract_part )
For example:
DBL_SIN 7 2 // fpu[7] = sin(fpu[2])
DBL_EXP 8 1 0 // fpu[8] += e ^ 1 = e
All unary operators have the same format: