The Shop > Electronics & IC Programing

STR$

<< < (2/6) > >>

vtsteam:
Don't remember a mask function, Andrew, but I got the old laptop out and ran QBasic, and can confirm that the output of VAL gives two characters for a positive number. A space (a placeholder for a sign) and the number itself.

We just have to trim off that space -- called in for dinner now, but we can do it with a function -- just have to look it up again after a bit of turkey in the interim!

vtsteam:
This should do the whole job without a table
Where C$ contains a binary 8 bit string
And result X contains the decimal number:



--- Code: ---X=0
FOR i = 8 to 1 step -1
E = VAL(MID$(C$,i,1))
X = X + (E*((2^(8-i)))
NEXT

--- End code ---

DavidA:
VT,

That looks as if it should do it.

I'll try it in the morning. I can run it as a subroutine at the end and just bypass the current method with the table.

I'm off to bed now.

Cheers.

Dave.

vtsteam:
If anyone is interested, you can still get good old QBASIC through links here and there are a bunch of tutorial resources and other fun stuff at:

http://www.petesqbsite.com/index.php

Joules:
For anyone who might like playing with basic and has an iPad this is a nice application.  I use it quite a bit for developing ideas and general play to keep my nostalgia alive and kicking

No association, just impressed customer.

Uh oh, my bad turns out the software now just crashes in iOS 8 so link removed.  Hope they get it fixed soon.  😠

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version