Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the fround word push its result to data stack. #69

Closed
edakawa opened this issue Oct 28, 2019 · 3 comments · Fixed by #101
Closed

the fround word push its result to data stack. #69

edakawa opened this issue Oct 28, 2019 · 3 comments · Fixed by #101
Assignees
Milestone

Comments

@edakawa
Copy link

edakawa commented Oct 28, 2019

Dear Mr. Phil Burk,

I'm a user of pForth and very happy to use it. By the way, I have a question
about the following parts,

$ pforth -q
7.7e fround . 8

7.7e fround f. 0.0000000 Stack<10> 8
THROW code = -45
Float Stack underflow!
bye
$

Is this the correct behavior? I expected the following behavior,

$ pforth -q
7.7e fround f. 8.000000
bye
$

I would like to think the fround word should push its result to floating point
stack. If this question was a known issue, I did very rudely, so I'm very sorry.

Finally, I modified csrc/pfinnrfp.h to get my expected behavior,

$ diff -C 2 pfinnrfp.h.orig pfinnrfp.h
*** pfinnrfp.h.orig     Mon Oct 28 15:50:40 2019
--- pfinnrfp.h  Mon Oct 28 15:30:43 2019
***************
*** 207,213 ****

      case ID_FP_FROUND:
!         PUSH_TOS;
!         TOS = (cell_t)fp_round(FP_TOS);
!         M_FP_DROP;
          break;

--- 207,211 ----

      case ID_FP_FROUND:
!         FP_TOS = (PF_FLOAT) fp_round(FP_TOS);
          break;
$

Sincerely,
Hajime Edakawa

@philburk
Copy link
Owner

You are right! According to the latest standard here:

http://lars.nocrew.org/forth2012/floating/FROUND.html

Since it returned a rounded "integer" value I assumed it would be on the integer stack. Not so.

Fixing this will break any pForth program currently using FROUND. So I will need to make sure users are warned.

If this question was a known issue, I did very rudely, so I'm very sorry.

No. Even if it was a known issue it would not be rude. I want to improve pForth. So every bug report is helpful. Even questions are helpful because then I know where to improve the documentation. You reported a bug and gave me the fix. I am grateful.

@philburk philburk self-assigned this Oct 28, 2019
@philburk
Copy link
Owner

@edakawa
Copy link
Author

edakawa commented Oct 28, 2019

Good to hear that. And,

No. Even if it was a known issue it would not be rude. I want to improve pForth. So every bug report is helpful. Even questions are helpful because then I know where to improve the documentation. You reported a bug and gave me the fix.

I really got courage from your comments. Thank you for giving me good advice!

@philburk philburk added this to the Version_2.0.0 milestone Oct 30, 2021
philburk added a commit that referenced this issue Oct 31, 2021
It used to push the result to the integer data stack.
That was wrong. It should go to the float stack.

Fixes #69
philburk added a commit that referenced this issue Oct 31, 2021
It used to push the result to the integer data stack.
That was wrong. It should go to the float stack.

Fixes #69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants