You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
PRINT displays single-precision quantities with up to 6 significant
digits, and other quantities with up to 16 digits. Extended-precision,
binary coded decimal, and quad integer values with 17 or 18 digits must
be printed via the STR$ function if all digits are to be displayed.
Originally posted by James Horner:
Any guesses why??
The type of N means to be single-precision (default for variables without type declaration in PB32) in your example, and single-precision has a precision of 6 to 7 decimal digits.
Try defining N as a double word with:
DEFDWD N
'and then
N = 23456789
PRINT N ' now gives 23456789
PRINT (N - 10000000 + 10000000) ' now gives 23456789
I stubled onto this oddity with PBDOS 3.2
using "PRINT" command.
I'm working with very large positive integers --in
declared as DOUBLWRD
With numbers N > 10,000,000 , PRINT N
showa on screen the a.bcd...E7 format
'and I lose the final digit.
However for such numbere, if I program it as
PRINT (N - 10000000 + 10000000) I get the full
eight digit numer on screen!
e.g.
N = 23456789
PRINT N gives 2.345678E7, But
PRINT (N - 10000000 + 10000000) gives 2345678 !
Any guesses why??
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: