Scientific Notation / Decimals Question

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
Pete
Site Admin
Posts: 882
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

Scientific Notation / Decimals Question

Post by Pete » Sun Jun 11, 2006 9:01 pm

Here's a question I got that maybe you guys can answer. I'm rather swamped with work at the moment!

If you're feeling really nice, email your answers to: nayrsllew[@]hotmail.com (Remove the brackets of course)
Hey Pete,

I was wondering if you might be able to answer a quick BASIC question for
me? I'm stumped. I used to use the language all the time, but it has been
many years and now I am confused.

I am trying to import data from a file, intepret it and eventually write
some data back.

The issue is it doesn't like decimals. The source file is like this....

datestamp,timestamp,val1,val2,val3,val4,volume

2004.06.17,00:00,1.2006,1.2006,1.2005,1.2005,4
2004.06.17,00:03,1.2005,1.2005,1.2004,1.2005,6
2004.06.17,00:05,1.2005,1.2005,1.2004,1.2004,2

And it is Val1,2,3,4 that I need to interogate. But I'm getting scientific
notation instead of numerical values to four digits. HELP!@#@ Do you have
any idea of I can fix this?

I am very grateful for any help you can offer.

Many thanks
Ryan

PS; My source code is below if it helps. Hope I haven't made too many coding
faux pas!

Code: Select all

CLS

SL = .005
TP = .001
SPREAD = .0002

openprice = 1.234445

buytp = openprice + SPREAD + TP
buysl = (openprice + SPREAD) - SL
selltp = openprice - TP
sellsl = openprice + SL

PRINT buytp, buysl, selltp, sellsl

recordno = 1

OPEN "c:\fdata1.dat" FOR RANDOM AS #1

FOR xx = 1 TO 20

GET #1, recordno, checkdatestamp
GET #1, recordno + 1, checktimestamp

FOR count = 2 TO 5
GET #1, recordno + count, checkprice

IF checkprice >= buytp THEN PRINT "BUYTP"
IF checkprice <= buysl THEN PRINT "buysl"
IF checkprice <= selltp THEN PRINT "selltp"
IF checkprice >= sellsl THEN PRINT "sellsl"

PRINT recordno, count, checkprice

NEXT count

recordno = recordno + 7

DO
LOOP WHILE INKEY$ = ""

NEXT xx

User avatar
Quibbler
Coder
Posts: 16
Joined: Tue Jan 24, 2006 7:29 am
Location: Trinidad and Tobago

Post by Quibbler » Mon Jun 12, 2006 7:00 am

You would be better opening your file for input that is as a sequential file. As it is you are doing almost everything wrong in your attempt to read the file as random. Which is why you are getting nonsense answers - nothing to do with scientific notation.

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo » Mon Jun 12, 2006 6:07 pm

BTW, a guy with a username of Kermit (as a guest) posted the same exact problem on Qbasic.com on 6/1/06, and was given several solutions by Mac on 6/4/06. I read Mac's solutions and suggestions, and they're good.

In my opinion, Pete, this guy is wasting our time.

*****

User avatar
Pete
Site Admin
Posts: 882
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

Post by Pete » Tue Jun 13, 2006 11:54 am

Actually, he sent this email to me on June 1st, but I didn't get around to doing anything with it until now...

When I'm busy, I let all of these QB questions and questions about my site just pile up, which kind of does a disservice to the people asking the questions, but I can't help it.

The other day when I posted this, I had about 25 QB-related emails to go through, all of them either asking QB questions or submitting stuff to my site. :)

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo » Tue Jun 13, 2006 7:08 pm

I understand, Pete. Maybe you should respond to these by telling them to post them at petesqbsite. I think it's as much effort as you having to do a proxy posting for them, and then perhaps getting more involved.

It just bothers me when these guys splatter their requests onto several forums, obtain answers, and then never provide any feedback. When they've been provided solutions, they should at least say "Thanks" or "Thanks, I already got a solution."
*****

User avatar
Pete
Site Admin
Posts: 882
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

Post by Pete » Wed Jun 21, 2006 1:26 am

Agreed.

Instead of proxy posting, I'll encourage them to post the questions themselves. That means that they have to register an account and then maybe they'll end up staying around.

Good idea!

Post Reply