Author Topic: Wiki notation glitch  (Read 4105 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Wiki notation glitch
« on: January 06, 2019, 11:54:44 am »
Making my little NumType function, I noticed a few little glitches in the wiki:

http://qb64.org/wiki/Variable_Types

If you'll look close, you'll see the min/max values for SINGLE/DOUBLE/_FLOAT:
-2.802597E-45
-4.490656458412465E-324
-1.18E−4932

These are all wrong -- obviously wrong, if one only takes a moment to think about them...

1E-2 translates to become 0.01
1E-3 becomes 0.001
1E-4 becomes 0.0001

So E-45 is VERY close to 0, and E-4932 is even closer to 0...

SINGLE and such doesn't run from 0 to limit...  They run from a large negative number to a large positive number.

Those negative signs AFTER the "E" need to either all disappear, or else become "+" signs instead.


***************

Same fix needed for the charts on the DATA TYPES page as well: http://qb64.org/wiki/Data_types
« Last Edit: January 06, 2019, 12:12:57 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Wiki notation glitch
« Reply #1 on: January 06, 2019, 12:41:17 pm »
Interesting but not something I ever studied...

So with this

a = -2.1E-45
PRINT a
a = -2.11E-45
PRINT a: END

a = -1.401298E-45
a = -2.802597E-45 (That's the lowest value as printed in the WIKI.)

If E-46 is used, the value is out of bounds and returns as zero; however, if a = 2.802598 is used, it still outputs the value of -2.802597E-45.

I guess I'm just happy I don't have anything I use that tests these boundaries.

Pete

OK, so since I still have some old QBasic books on the shelves...

                                        Max                                                 Min
Integers:                               32,767                                         -32,768
Long Integers:          2,147,483,647                             -2,147,483,648
+Single Precision:     3.402823 E+38                             1.401298 E-45
-Single Precision:     -1.401298 E-45                            -3.402823 E+38
+Double Precision:   1.797693134862315 D+308        4.9406564584412465 D-324
-Double Precision:    -4.9406564584412465 D-324     -1.797693134862315 D+308

The WIKI differs in Single Precision, which is listed as -2.802597E-45 instead of the MS QB book limit of -1.401298 E-45

I don't have a copy of QB45 running right now, or I'd test my code above to see if it gave a different output.

Edited to change -32,767 to correct value of -32,768. Thanks RonB.
« Last Edit: January 06, 2019, 03:17:36 pm by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Wiki notation glitch
« Reply #2 on: January 06, 2019, 01:20:31 pm »
So SINGLE is basically from: -3.402823 E+38  to +3.402823 E+38  for absolute min/max value, with greatest precision to zero being -1.401298 E-45  to +1.401298 E-45... 


https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Wiki notation glitch
« Reply #3 on: January 06, 2019, 01:27:13 pm »
It's basically what you find on the web when searching for IEEE 754...
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline RonB

  • Newbie
  • Posts: 14
    • View Profile
Re: Wiki notation glitch
« Reply #4 on: January 06, 2019, 02:45:53 pm »
Sorry, I can't resist...
The (16-bit) Integer Minimum Value should be -32768 not -32767. Prove it yourself:
a% = -32767
PRINT a% ' will show -32767
a% = a% -1
PRINT a% ' will show -32768
a% = a% -1
PRINT a% ' will show (positive) 32767 as it should

FellippeHeitor

  • Guest
Re: Wiki notation glitch
« Reply #5 on: January 06, 2019, 03:04:04 pm »
Sorry, I can't resist...
The (16-bit) Integer Minimum Value should be -32768 not -32767. Prove it yourself:
a% = -32767
PRINT a% ' will show -32767
a% = a% -1
PRINT a% ' will show -32768
a% = a% -1
PRINT a% ' will show (positive) 32767 as it should

True. But that's not wrong in the wiki.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Wiki notation glitch
« Reply #6 on: January 06, 2019, 03:20:42 pm »
Corrected that "typo" in the MS-QB chart I posted above. It is correct in the book. In all fairness, I'm over twice the age of that book, but I have a harder cover!

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
Re: Wiki notation glitch
« Reply #7 on: January 06, 2019, 03:25:14 pm »
There:

 [ You are not allowed to view this attachment ]  
« Last Edit: January 06, 2019, 04:14:03 pm by FellippeHeitor »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Wiki notation glitch
« Reply #8 on: January 06, 2019, 03:30:44 pm »
But my chart's prettier, 'cause it's homemade.

Pete :D
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
Re: Wiki notation glitch
« Reply #9 on: January 06, 2019, 03:41:33 pm »
My horse is amazing.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Wiki notation glitch
« Reply #10 on: January 06, 2019, 03:54:24 pm »
There:

 [ You are not allowed to view this attachment ]  

The difference here and the wiki is the +/- in the picture...

Singles goes from -3.4E38 to -1.4E-45, and then from +1.4E+45 to +3.4E+38...

It’s from a large negative number, to almost zero, and then from almost zero to a large positive number.



The way the wiki is wrote, it seems as if this would work:

IF value >= -1.4E-45 AND value <= 3.4E38 THEN value_type = SINGLE

Only problem with that:  value = -128 — by the boundaries above, value wouldn’t be a valid SINGLE.  -128 is < -1.4E-45...


https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Wiki notation glitch
« Reply #11 on: January 06, 2019, 05:08:17 pm »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/