Author Topic: PRINT USING Bug?  (Read 2374 times)

0 Members and 1 Guest are viewing this topic.

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
PRINT USING Bug?
« on: June 01, 2021, 08:09:01 pm »
In researching for the post on 128bit numbers, I've isolated the following code and believe that this is a bug.

I am running on Linux Ubuntu 20.04.2 LTS, and screen print is attached.

I am print the following number: 10.349449797507

And regardless of whether I use FLOAT, DOUBLE or SINGLE type, if my program prints this out with a USING mask, I get garbage after the end of the number.

There are occasions where your mask must be larger than a number because a program may not know how big or small the number you are to PRINT.

This should not happen. The rest of the mask after the last digit should be all ZEROES.

The screen print shows the various values printed after the valid end of the number.

Code: QB64: [Select]
  1. DIM result AS _FLOAT
  2. DIM answer AS DOUBLE
  3. DIM result2 AS SINGLE
  4.  
  5.  
  6. result = 10.349449797507
  7. answer = 10.349449797507
  8. result2 = 10.349449797507
  9.  
  10. PRINT USING "The value is:  ###.#########################"; result
  11. PRINT USING "The value is:  ###.#########################"; answer
  12. PRINT USING "The value is:  ###.#########################"; result2

  [ You are not allowed to view this attachment ]  
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)