# Qbasicnews.com

## QBasic => QB Discussion & Programming Help => Topic started by: gummo on May 27, 2008, 01:08:30 AM

 Title: Keeping the the zero at the end of decimals Post by: gummo on May 27, 2008, 01:08:30 AM Sorry if this sounds stupid, but I haven't used Quick Basic in years, and I'm attempting to make an economic sim game. QB drops the zeros that I use in decimal numbers,  and I was wondering if there was a way around that, that wasn't too cumbersome. Basically what I'm trying to do is to manipulate the price of goods and the player's income. Also, if anyone is aware of tutorials in making this sort of game I'd be very grateful. Thanks much.-s.davis Title: Re: Keeping the the zero at the end of decimals Post by: Ralph on May 27, 2008, 02:27:10 PM "True" numbers don't have leading  or trailing zeroes.  So, if you want to use, say,x = 45.60, you cannot use a "number"; you have to use strings.  So, you would code the above as x\$ = "45.60".If you want to use numbers, and your results are, say, x = 45.6, you can print this out as 45.60 by two methods: either you convert it to a string with a trailing zero, say by the code,  x\$ = STR\$(x) + "0", which would be too straneous and very indirct, or, best by a long shot, you can use the QB PRINT USING statement.  Read up on it in the QuickBASIC 4.5 IDE by clicking on Help, then Index, then P, then on the PRINT USING statement.Once you master that bit of code, practice it and, if you still have a problem, post back, showing the respective code, stating your expected results, and explaining any problem you are having. Title: Re: Keeping the the zero at the end of decimals Post by: LPG on May 28, 2008, 01:59:10 AM The following code uses print using to print 1234.5 as \$1,234.50Code:clsx = 1234.5print using "\$\$####,.##";xin the print using command: \$\$ means put a dollar sign in front # means print a digit so four means print four digits , before the dot means put a comma every 3 spaces  . means put the decimal point hereif you made the codeCode:clsx = 1234.5print using "\$\$########,.##it would output the same but would also work if x = 12345678.5 where the first example wouldn't.hope that helpedLPG