AllExperts > Qbasic, Quickbasic 
Search      
Qbasic, Quickbasic
Volunteer
Answers to thousands of questions
 Home · More Qbasic, Quickbasic Questions · Answer Library  · Encyclopedia ·
More Qbasic, Quickbasic Answers
Question Library

Ask a question about Qbasic, Quickbasic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Alex Barry
Expertise
I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, c/c++, python, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

Experience
Hobby programming since 2000

I no longer belong to any community programming groups, but do have knowledge of *basic dialects and C/C++

 
   

You are here:  Experts > Computing/Technology > Basic > Qbasic, Quickbasic > need a perfect data to save!!

Qbasic, Quickbasic - need a perfect data to save!!


Expert: Alex Barry - 5/17/2009

Question
dear alex,
for some reason i need to store a perfect number in a file.
by perfect number i mean like 9865986498659589745895698569 not 9D+23.
1.which varible should i use?
in long integer, if i input a 9 digit number it is storing it perfectly in a file.but whaen i am using single\double precision, it is storing number in file like 9.2D+28.the number is not like what i wnat.i want every digit of number.

2.which variable will occupy least memory and handle big digit numbers without making them 10-to-the-power?

3.i used long integer to save big digit number in a file.that should occupy 4 byte but it is showning 11 bytes.why? is this because of 32 bit operating system? As i am trying to write a data compression program i need the output file as short as possible.

Dear alex i think i have given u a strange ques but there is no one in my area to answer me and if i ask this they will not answer as they think i am wasting my time.
i hope u give the answer. i cannt wait!
saif


Answer
Hi, Saif,

Sorry for the delay.

1. As far as storing a large number, if there is no decimal, use a long integer - if there is, you'll need to use a double.

2. Once you get into numbers with many digits, you'll have to use a long, or a double.  At this point, it won't be about how small you can make it, because you'll be storing large numbers

3. When you save information to a file, it transforms all data into ASCII equivalents, which means you won't use the same amount of memory in a file that QBasic would use when you are dealing with the variable

If you are making something to compress information, you may want to do something like this:

First, download a DOS-compatible compression program.  I suggest gzip:
ftp://tug.ctan.org/tex-archive/tools/zip/info-zip/MSDOS/gzip124.exe

From there, after doing your OPEN "file" FOR OUTPUT AS #x ... CLOSE #x
you would do a SHELL( "gzip file" )
and voila, that should compress that the best possible - you may have to tinker with the gzip command line, but for smaller files, you won't see much compression, but the bigger the file, the more compression you can get.

I hope that helps you out - if you have any other questions, I'll try and get back to you a little quicker.
-Alex

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.