C.Basic - Reference

  Enterance > English Top > C.Basic > Reference

Running Modes - "Integer" and "Real" Mode

C.Basic supports two different running modes, "Real (Number) Mode" as same as genuine Casio Basic does, and "Integer Mode" that allow handling only integer. The Integer Mode was implemented to C.Basic for faster operation.

In order to set either of those running modes, to set "Real Mode" declare one of followings;


to set "Integer Mode" declare one of followings;


In C.Basic real number is implemented in double-precision real type, so real and doulbe-precision is the same.

You can set default settings in Setup page and in order to set default running mode, set "Execute mode" as Dbl# or "Int%".

The declared running mode in source file has priority to setting in the Setup page.

In "Integer Mode", result value of calculation have to be given in integer, but the operation speed is faster than in "Real Number Mode" by factor of 1.5.

If you set "Integer Mode" but want to evaluate a specific expression in real number (double-precision), simply add prefix # before the expression you want. the expresion after # is evaluated in doulbe-precison without error. But, please note the evaluation result in double-precision is converted to integer, so the expression after # returns integer value by rounded to integer to fit the "Integer Mode".

#100×Frac 1.23 + 5

In "Integer Mode", Flac 1.23 is in error and the following codes cannot run, but the prefix # enable evaluation in double-precision of expression after # to end of line or ":" (muti-statement command). 
#(Frac 1.23×100 + 5)

So, result of this line is 28. If this code runs in "Real More", it also results in 28.

If # is in middle of expression, a part of the expression after # to end of line or muti-statement command.

100×#Frac 1.23 + 5

Interpretation of this expression is
100×#(Frac 1.23 + 5)
so it results in 523 in "Real Mode" and 500 in "Integer Mode".


Type of Number

Genuine Casio Basic use decimal number with internally 15 digits and 2 digits of exponent notation. On the other hand, C.Basic basically use a double precision real number type (8 Bytes) and 4 Bytes integer type, since C language of Casio SDK has the same specification.
A range of number that the double precision real number can handle is
±9.88131291682493e-323 to ±1.7976931348623151e+308
This range is wider than genuine Casio Basic, but operation is carried out in binary, so we have to keep in mind that handling of number after decimal point may cause possible calculation errror.

We can put prefix 0X or 0B like C language to value of constant and then we can use hexadecimal or binary number within 32 bits.
(example) 0XFF, 0B10100110
(example) 0xAB, 0b10100110


Type of Variable

As well as genuine Casio Basic, C.Basic uses single letter variables, 26 capital letters A to Z and also small letters a to z.

String variable with more than 2 letters is not supported by C.Basic as well as genuine Casio Basic.

C.Basic provides independantly real number type of variables (A - Z, a - z) and integer type of variables (A - Z, a - z). Real number variables are used in real number running mode and also integer variables in integer running mode. In ternally the different type of variable still use same letter, so we should put % suffix for integer variables (A% - Z%, a% - z%), put # suffix for real number variables (A# - Z#, a# - z#).

When an integer variable with % suffix is used in real number mode would not be problem. But on the other hand, if a real number variable is used in integer mode we have to understand that read-out value from the real number variable is rounded integer.
When real number value does not fit in the range of integer number, the value is changed to 0 (zero).

(example) '#CBINT //set to integer mode
       1.2345→A# // 1.2345 is rounded to 1 then 1 is substituted.

(example)   A%→A#
 Copy integer variable A to double-precision variable A.
 Copying integer value to double-precision variable is no problem. But double-precision value is going to be contained into integer variable, this may have a problem, in case the value does no fit into a range of integer (32 bits) the value is changed to 0.

At initialization of variable, we can use a format 0→A ~ Z(genuine Casio Basic can do this) and also we van set type of variable.
0→A# ~ Z#   // initialize double-precision variable
0→A% ~ Z%  // initialize integer variable



Text screen and graphics screen are independently implemented in C.Basic as well as genuine Casio Basic. Actually only one VRAM, called Display-VRAM is used to display to LCD by commands.

There are 3 VRAMs;
- Display-VRAM is used to output to LCD
- Text-VRAM is an RAM area to save data for text screen
- Graphics-VRAM is an RAM area to save data for graphics screen

Those 3 VRAMS with same size are implemented.

When a text display command runs in "text display mode", the process sends data to Display-VRAM. When a text display command runs in "graphics display mode", the process retract Display-VRAM to Graphics-VRAM at fisrt then transfer Text-VRAM to DisplayVRAM, and then display text output in Display-VRAM.

When a text display command runs repeatedly, skipping retraction to Graphics-VRAM and transferring to Text-VRAM, then only drawing text on -Display-VRAM is continued (still in "text display mode").

Still in this "text display mode" when a graphics command runs, retract Display-VRAM to Text-VRAM, then resume Graphics-VRAM to Display-VRAM, and then draw graphics in Display-VRAM (switch to "graphics display mode").

As you see above, memory area such as Text-VRAM and Graphics-VRAM are NOT directly used for output to LCD, but merely data storage area. So once Text mode and Graphics mode are switched, at every time of this VRAM transferring is carried out among VRAM, Text-VRAM and Graphics-VRAM.


Drawing on LCD

In order to draw text or graphics on screen in fx-9860G / fx-9860GII, data in VRAM is transferred to LCD.

Transferring to LCD includes quite a few overhead, so it takes totally long time (it is inefficient) to transfer data to LCD (refresh) at every single time when a draw command runs.

To get rid of the inefficiency C.Basic provides Refresh Control function. You can set to supress the refresh at every single time when a draw comamnd runs, and can set to carry out refresh in regular intervals (this setting is available in Setup page and also by command).

With the setting for refresh in regular intervals, the last command in repeating drawing operation may lose a chance to refresh, then before refreshing to reflect the last drawing command the next command possibly runs.

In order to avoid this problem, we want to force the refresh then use PutDispDD to refresh screen.


Compatible Commands with Casio Basic

List of Compatible Commands supported in C.Basic

◢ (Disps)

If ~ Then ~ Else ~ IfEnd
Lbl ~ Goto
=  ≠  =  >  <  ≥  ≤

Dsz / Isz



For ~ To ~ Step ~ Next
While ~ WhileEnd
Do ~ LpWhile

Cls / ClrText / ClrGraph
Plot / PlotOn / PlotOff / PlotChg
Line / F-Line
Vertical / Horizontal

PxlOn / PxlOff / PxlChg
Graph Y=

SketchNormal / SketchThick / SketchBroken / SketchDot
S-L-Normal / S-L-Thick / S-L-Broken / S-L-Dot

CoordOn / CoordOff
GridOn / GridOff
AxesOn / AxesOff
LabelOn / LabelOff

Xmin Ymin Xmax Ymax Xscl Yscl Xfct Yfct Xdot
Deg / Rad / Grad

And / Or / Not / Xor

Abs / Int / frac / Intg
log ln
10^x / e^x
sqr x^2
sin / cos / tan
sin^-1 cos^-1 tan^-1
sinh / cosh / tanh
sinh^-1 / cosh^-1 / tanh^-1

femto / pico / nano / micro / milli / Kiro / Mega / Giga / Tera / Peta / Exa

°(deg) / r(rad) / g(gra)
° / >DMS


StoPict / RclPict

Ran# RanInt#(
Rnd RndFix(
Norm / Fix / Sci
Eng / EngOn / EngOff


inserted by FC2 system