Announcement

Collapse
No announcement yet.

PB DOD "PRINT" Oddity!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PB DOD "PRINT" Oddity!


    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??

    ------------------

  • #2
    I can't answer your question but when dealing with numbers like
    that, I usually use something like:
    Code:
    fmt$ = "##,###,###.##"   ' or use whatever format style that
    print;using$(fmt$,n)     ' floats your boat.
    This gives proper display 99 times out of a hundred.


    ------------------
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      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

      Best Regards,

      Arthur.

      ------------------
      "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

      Comment


      • #4
        Help file under PRINT tells you why..
        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.
        .. which is, "because that's the way it works."

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          As I said in the riginal post, N was declared as
          a double word variable!

          ------------------

          Comment


          • #6
            You didn't read my post!
            N is double word
            N = 98765432
            PRINT N gives 8.876543E7

            BUT, PRINT (N - 10000000 + 10000000)
            gives the 8 digit integer 98765432

            Nothing is different about the number in question
            but PRINT renders then differently.

            ------------------

            Comment


            • #7
              Originally posted by James Horner:
              You didn't read my post!
              I apologize!
              PB32 has this problem - to be safe you must use the trick of Mr. Bishop says above.
              PB35 runs your code fine!

              Best Regards,

              Arthur.




              ------------------
              "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

              Comment

              Working...
              X