bugGforth - Bugs: bug #49798, s>number? throws in a random 0

 
 

bug #49798: s>number? throws in a random 0

Submitted by:  None
Submitted on:  Wed 07 Dec 2016 10:36:52 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: Anton Ertl <anton>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 08 Dec 2016 06:29:23 PM UTC, comment #2:

Sorry, my bad. I didn't realize that was what d meant. Invalid indeed.

Anonymous
Thu 08 Dec 2016 08:25:46 AM UTC, comment #1:

Note that the documented stack effect is:

s>number? ( addr u -- d f )

d is a double-cell integer, and .s will show two cells for it, with the 0 being the most significant half of the d (double-cell integer). If you do

clearstacks s" 1001" s>number? . d. .s

"." prints the flag, "d." prints the d, and .s shows that nothing is left.

Anton Ertl <anton>
Project AdministratorIn charge of this item.
Wed 07 Dec 2016 10:36:52 PM UTC, original submission:

according to this http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Line-input-and-conversion.html#index-s_003enumber_003f-_0040var_007b-addr-u-_002d_002d-d-f---_007d--gforth-2160 s>number? should just leave a flag indicating success on the top of stack, followed by the number the string was converted to. However, when I run it, there is a 0 between those two values on the stack. It is always a zero, regardless of what string I give it so far. To test, just do something like

clearstacks s" 1001" s>number? .s

Which will give

<3> 1001 0 -1

Either the code or the documentation must be wrong.

I'm on gforth 0.7.9_20160923 amd64.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by anton (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 08 Dec 2016 08:56:55 AM UTCantonOpen/ClosedOpen=>Closed
    Thu 08 Dec 2016 08:25:46 AM UTCantonStatusNone=>Invalid
      Assigned toNone=>anton

    Back to the top


    Powered by Savane 3.1-cleanup1