Setting The Value Of An Obcd - Casio ClassPad 300 Programming Manual

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

Advertisement

For example, let's say you want to store 1750. The value of the mantissa will be 1750.
But remember we must calculate the exponent as if 1.750 is actually stored in the
mantissa. Therefore the exponent needs to be 10^3 (because 1.75 * 10^3 = 1750). Since
1750 is positive the OBCD's exponent starts at 1000. We then add the exponent value
(3) to get:
1000 + 3 = 1003
which means that our exponent has the value of 1003.
The OBCD representation of 1750
eF
1
2
3
4
5
0
1
7
5
0
0
Now let's try –0.0065. The mantissa will be 65, so we need the exponent to be –10^-3
(6.5 * -10^-3 = -0.0065). Since our value is negative this time we need to add to 6000.
So the value of the exponent is:
6000 + (-3) = 5997
The OBCD representation of –0.0065
eF
1
2
3
4
5
0
6
5
0
0
0
Finally, let's look at the value 2.25. This will be stored in the mantissa as 225. The value
we want for an exponent is 10^0 since 2.25 * 10^0 = 2.25. Again, our number is positive
so we add to 1000: 1000 + 0 = 1000. So the representation of 2.25 is:
The OBCD representation of 2.25
eF
1
2
3
4
5
0
2
2
5
0
0
Here are some more examples that of exponents and their OBCD representation:
Exponent Value
eS
0
0
10^-999
0
10^-1
0
10^0
1
10^1
1
-10^1
6
-10^-1
5

Setting the Value of an OBCD

To assign a value to an OBCD number there are several functions that you can use. The
first three we will look at will look at can be used to set an OBCD to a whole number:
word Cal_setn_OBC(word wx, OBCD * x);
word Cal_shortto_OBC(short wx, OBCD * x);
word Cal_longto_OBC(long wx, OBCD * x);
6
7
8
9
10
11
0
0
0
0
0
0
6
7
8
9
10
11
0
0
0
0
0
0
6
7
8
9
10
11
0
0
0
0
0
0
e1
e2
0
0
0
0
9
9
0
0
0
0
0
0
9
9
12
13
14
15
16
0
0
0
0
0
0
12
13
14
15
16
0
0
0
0
0
0
12
13
14
15
16
0
0
0
0
0
0
e3
0
1
9
0
1
1
9
17
18
19
eS
e1
e2
0
0
1
0
0
17
18
19
eS
e1
e2
0
0
5
9
9
17
18
19
eS
e1
e2
0
0
1
0
0
86
e3
3
e3
7
e3
0

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents