EasyManuals Logo
Home>Casio>Calculator>ClassPad 300

Casio ClassPad 300 Programming Guide

Casio ClassPad 300
125 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #90 background imageLoading...
Page #90 background image
These functions also return an error code and place the result in x.
Converting OBCDs
There are also several functions that convert OBCDs into different data types. An OBCD
can be converted to a short, long or string. The functions to convert an OBCD to a short
or long are similar to the functions we’ve already seen:
word Cal_toshort_OBC(OBCD *x, short *wx); //Convert an OBCD to a short
word Cal_tolong_OBC(OBCD *x, long *wx); //Convert an OBCD to a long.
Once again, be careful not to expect the conversion as the return value:
OBCD x;
long y;
word error_code;
Cal_setn_OBC(6, &x); // set x = 6
error_code = Cal_tolong_OBC(&x, &y); // set y = x;
There are many different functions that can be used to convert an OBCD to a string.
These functions differ by which form of the OBCD is placed in the string – normal mode,
scientific notation, etc. We will look at four of these functions. To view all of the
available functions, refer to the ClassPad 300 SDK API Reference Guide Strings-
>Functions to Convert OBCD/CBCD datatypes to strings.
//Changes the OBCD value to normal mode and places it in str.
word CP_Norm_OBC (OBCD *x, CP_CHAR str[], short mode);
//Changes decimal portion of OBCD to fixed size and places it in str
word CP_Fix_OBC (OBCD *x, CP_CHAR str[], short dig);
// Changes the OBCD value to scientific notation of precision dig and
// places it in str.
word CP_Sci_OBC (OBCD *x, CP_CHAR str[], short dig);
// Change an OBCD object to a 15 digit string in normal mode.
word CP_15digit_OBC (OBCD *x, CP_CHAR str[]);
Here is an example on how to convert an OBCD to a string in different forms:
OBCD x;
CP_CHAR buffer[15];
Cal_setn_OBC(1525, &x); // set x = 1525
x.obcd1.exponential = 0x1001;
CP_15digit_OBC(&x, buffer); // puts 15.25 in buffer
CP_Norm_OBC(&x, buffer, IM_MODE_NORM1); // puts 15.25 in buffer
CP_Fix_OBC(&x, buffer, 4); // puts 15.2500 in buffer
CP_Sci_OBC(&x, buffer, 4); // puts 1.525e1 in buffer
90

Table of Contents

Other manuals for Casio ClassPad 300

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Casio ClassPad 300 and is the answer not in the manual?

Casio ClassPad 300 Specifications

General IconGeneral
BrandCasio
ModelClassPad 300
CategoryCalculator
LanguageEnglish

Related product manuals