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

 
 

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

Submitter:  None
Submitted:  Wed 07 Dec 2016 10:36:52 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  anton
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group administrator
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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-12-08 anton Open/ClosedOpen Closed
    2016-12-08 anton StatusNone Invalid
        Assigned toNone anton

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code