C++ Functions; Cbcd Data Structure; Setting The Value Of A Cbcd - Casio ClassPad 300 Programming Manual

Sdk programming guide
Hide thumbs Also See for ClassPad 300:
Table of Contents

Advertisement

C++ Functions

It is important that you understand and can use the OBCD functions that we've covered
up to this point. This is how doubles are stored and used natively on the ClassPad. There
are, however, some functions available in C++ that are more human readable. You can
view all of these functions in the ClassPad 300 SDK API Reference Guide under Math
Fuctions->C++ Math Functions. Here is an example of how they work:
OBCD x, y;
Cal_longto_OCB(170, &x);
y = sin(x);
if(y == x)
{
x = x * y;
}
else
{
y = x + y;
}
As you can see, these are much more intuitive than the C functions. Remember that these
functions will only work in C++; you cannot use them in C.

CBCD Data Structure

A CBCD is used to hold a complex number. Its structure is defined as:
typedef struct cbcd {
OBCD
repart;
OBCD
impart;
} CBCD;
As you can see from the structure, a CBCD is really just two OBCDs. One OBCD –
repart – holds the real part of the CBCD and the second OBCD – impart – holds the
imaginary part.

Setting the Value of a CBCD

Since a CBCD is just 2 OBCDs, setting the value of a CDCB is just like setting the value
of 2 OBCDs. For example, if you wanted to create the value 2.5 + 3i you just have to
create a CBCD with real part 2.5 and imaginary part 3. Here is the code to do that:
CBCD x;
Cal_longto_OBC(25, &x.repart);
// change the real part's exponent to 10^0
x.repart.obcd1.exponential = 0x1000;
Cal_longto_OBC(3, &x.impart);
The result is the value 2.5+3i being stored in x.
// set x's real part to 25
// set x's imaginary part to 3
91

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents