• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Use of the SINGLE variable type in Oshonsoft Basic

Status
Not open for further replies.

Mellbreak

New Member
Can anyone tell me if it is possible to use exponents in Oshonsoft BASIC? If I declare a variable type as "single", the following compiles.

Dim xx As Single

xx = 4294967296 * 180000000


but...

xx = 4294967296 * 180e6

does not. I get the error "not a valid Single type constant."

Am I using the wrong method to represent the exponent? Also tying to display the value of xx on an LCD gives some very odd results using Lcdout #xx.

Any help gratefully received.
 

ericgibbs

Well-Known Member
Most Helpful Member
hi,
Do you have the Math32 option from Oshonsoft.?

The '#' prefix will only work for a maximum value of 65535 decimal, you will get incorrect results for higher than 65K.

I have never seen the use of exponents with Oshonsoft

EDIT,
This a sample program to show the LONG to ASC conversion subr in ASM

Copy and paste the 'bin2asc' section and its Dim's
 
Last edited:

Mellbreak

New Member
Thanks for the reply Eric. Yes I do have the Math32 option, but there seems little info out there to say how it is used. Thanks for the file - I'll have a look at your routine and see if I make use of it. If anyone does have any information regarding the use of the Single variable type or its structure I would appreciate any info.
 

jjw

Member
I have not succeeded to declare single variable with exponent.
Only information about single variable is on Oshhonsoft home page. It is 4 byte modified IEE754 format with 7-digit precision.
Lcdout #x shows single variable with 7-digits
eg. 98765.123 -> 98765.12
9876.123 -> 9876.123
98765432 and negative numbers display garbage.

Single variable could be displayed with exponent in Lcdout by scaling it between 1-9 by multiplying or dividing by 10 and counting the exponent.
For example positive single x greater than 10

exponent=0 ' byte variable
while x>=10
x=x/10
exponent=exponent+1
wend

then converting integer and decimal parts to long variables:

i=x
x2=x-i ' x2 is single
j= 100000*x2 ' 6 digits decimal
Lcdout #i,"."#j,"E",#exponent

If x is smaller than 1 then repeat with multiplying by 10
Lcdout #i,"."#j,"E-",#exponent

Negative numbers should be handled separately eg. by first converting to positive with multiplying by -1.
 
Last edited:

Mellbreak

New Member
jjw,

Thanks for the reply. I've come to the conclusion that Oshonsoft BASIC is not really up to the job that I need it to do. Hopefully though your efforts will be of some use to others.

Best regards,

Mellbreak
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading

 
Top