EasyManuals Logo

CipherLab 8300 User Manual

CipherLab 8300
263 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 #31 background imageLoading...
Page #31 background image
19
Chapter 3 Basics of the CipherLab BASIC Language
About Real Number
Every decimal integer can be exactly represented by a binary integer; however, this is not true for
fractional numbers. It is therefore very important to realize that any binary floating-
point system
can represent only a finite number of floating-
point values in exact form. All other values must be
approximated by the closest representable
value. For example, even common decimal fractions,
such as decimal 0.0001, cannot be represented exactly in binary. (0.0001 is a repeating binary
fraction with a period of 104 bits!)
REM Floating-point error
fnum1!=99999.1
fnum2!=99999.0
SET_PRECISION(4)
print fnum1!
REM : It prints “99999.1016” instead of “99999.1000”.
print (fnum1!-fnum2!)*100
REM : It prints “10.1563” instead of “10”.
IF (fnum1!-fnum2! <> 0.1) THEN
print "Not equal"
ELSE
print "Equal"
END IF
REM : It prints “Not equal” for the comparison of “99999.1-99999.0” and “0.1”
We suggest not handling floating-
point values directly but converting them to integers first. After
calculations, convert integers to real numbers if necessary. For example, in order to process the
expression of 1.82-1.8, you are advised to modify the expression to something like 182-180, and
then divide the result by 100 to get the actual result of 0.02.
When the floating-
point values are displayed, printed, or used in calculations, they lose precision.
Instead of using floating-
point, use integer or long to perform arithmetical or logical calculations. If
there is a need to display a fractional number on the screen, convert the integer or long to a string
and add the decimal point in the proper place. For example,
num1&=999991
num2&=999990
num3&=(num1&-num2&)*100
print (num1& \ 10) ; "." ; (num1& MOD 10)
REM : It prints “99999.1”
print (num3& \ 10) ; "." ; (num3& MOD 10)
REM : It prints “10.0”

Table of Contents

Other manuals for CipherLab 8300

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the CipherLab 8300 and is the answer not in the manual?

CipherLab 8300 Specifications

General IconGeneral
BrandCipherLab
Model8300
CategoryPDA
LanguageEnglish

Related product manuals