3

I have a QBASIC program that basically consists of formulas and constants, and I want to translate the formulas and constants into a C++ programm. Since the formulas are not rocket science and the program is well documented, I have no problem translating the program, although I have not used or seen QBASIC before.

However, there is an initialization of a variable that reads abc(15) = 9.207134000000001D-02, and I am not sure how to interpret the D-02. I guess I should translate it like abc[15] =0.09207134...., but I'd like to verify if this is correct.

René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
  • I think you have it and you could start with a google search on "QBASIC number notation with a D" and find answers like - D notation: If the answer's a long number, the computer usually prints a D instead of an E. Like the E, the D means "move the decimal point". – tawman Jan 18 '11 at 21:48

2 Answers2

3

If I recall correctly D-02 means times ten raised to the power minus 2.

So 8.309618000000001D-02 = 8.30961800000000 x 10^(-2)

which is roughly 0.08309618

I also think the D means the type of the number is a double.

EDIT: It's been ages since I wrote any QBASIC code

tenor
  • 1,095
  • 6
  • 8
  • Link online http://www.google.com/url?sa=t&source=web&cd=3&ved=0CCkQxQEwAg&url=http%3A%2F%2Fdocs.google.com%2Fviewer%3Fa%3Dv%26q%3Dcache%3A626VsOaeLrYJ%3Awww.quia.com%2Ffiles%2Fquia%2Fusers%2Fsmvin%2FQBasic%2FChp-3-notes-2nd-edition.doc%2Bqbasic%2Bnumber%2Bnotation%26hl%3Den%26gl%3Dus%26pid%3Dbl%26srcid%3DADGEESjBhcghrOoC1PESXvRQ3H2X4jbKeHnhRAzIeqsc22hE3SiHIdHqsaEGNTT4qrVyoTPuopz-xcU07QY5YrAh88fxpE6ErVhn1LZ4CioF27cCvppZmrimxt4uN-fwD89QWsCFAwpT%26sig%3DAHIEtbR0v7fXuVSf0ksGnYXCtcgyQay6LA&rct=j&q=qbasic%20number%20notation&ei=0A82TaLECYO8lQfz-PCzCg&usg=AFQjCNFs1mh85XloTs4H-4vR9K99wCjEww&cad=rja – tenor Jan 18 '11 at 22:16
1

Yes he is right the D means that the number is a double and the -2 after the D means it is multiplied by 10 to the power of negative 2 which means it is 0.08309618 to the precision of qbasics double precision numbers which is 52 or 54 bits If I remember corectly

John Einem
  • 51
  • 3