Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #14702

Re: CfV: S>F and F>S

From mhx@iae.nl (Marcel Hendrix)
Subject Re: CfV: S>F and F>S
Newsgroups comp.lang.forth
Message-ID <19171400958435@frunobulax.edu> (permalink)
Date 2012-08-03 21:18 +0200
References <2857190.v9o6eJ1jg5@sunwukong.fritz.box>
Organization Wanadoo

Show all headers | View raw


Bernd Paysan <bernd.paysan@gmx.de> writes Re: CfV: S>F and F>S
[..]
> I don't think we have to remove it.  We simply have to state that if the 
> floating point number doesn't fit into an integer, this is an ambiguous 
> condition.  We could specify F>S to have the same rounding mode as F>D, 
> but then, yes, we have the problem that F>D does not specify a rounding 
> mode (which is not really nice to easily write portable programs).

I am probably going to end up with egg on my face.

F>D                 "f-to-d"                                          FLOAT
     ( -- d ) ( F: r -- )
     d is the double-cell signed integer equivalent to the integer portion of
     r. The fractional portion of r is discarded. An ambiguous condition
     exists if the integer portion of r cannot be precisely represented as a
     double-cell signed integer.


*The fractional portion of r is discarded*

Why do I need to know the rounding mode for this?

1.0001e F>S . 1
0.5e    F>S . 0
0.999e  F>S . 0
-0.999e F>S . 0
-1e     F>S . -1

Yes, I must do something to the 'rounding mode' to get this *integer 
portion*, but the Forth code does not need to know what that is to
recognize I have provided the correct result.

Note also that the spec. says "SIGNED integer equivalent." Doing 
F>D DROP  is certainly not preserving the sign, so I'd argue it is 
against the spirit of F>D .

-marcel

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

CfV: S>F and F>S anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-02 16:51 +0000
  Re: CfV: S>F and F>S mhx@iae.nl (Marcel Hendrix) - 2012-08-02 22:28 +0200
    Re: CfV: S>F and F>S Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-02 23:36 +0200
  Re: CfV: S>F and F>S Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-08-03 04:39 -0700
    Re: CfV: S>F and F>S Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-03 19:56 +0200
      Re: CfV: S>F and F>S mhx@iae.nl (Marcel Hendrix) - 2012-08-03 21:18 +0200
        Re: CfV: S>F and F>S anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-04 09:50 +0000
          Re: CfV: S>F and F>S Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-04 21:51 +0200
            Presence of standard words (was: CfV: S>F and F>S) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-05 11:07 +0000
              Re: Presence of standard words (was: CfV: S>F and F>S) stephenXXX@mpeforth.com (Stephen Pelc) - 2012-08-05 11:34 +0000
                Re: Presence of standard words (was: CfV: S>F and F>S) Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-05 13:59 +0200
                Re: Presence of standard words (was: CfV: S>F and F>S) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-08-06 11:22 +0000
        Re: CfV: S>F and F>S Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-08-04 04:50 -0700
          Re: CfV: S>F and F>S stephenXXX@mpeforth.com (Stephen Pelc) - 2012-08-04 12:30 +0000
            Re: CfV: S>F and F>S C G Montgomery <cgm@physics.utoledo.edu> - 2012-08-05 09:14 -0400
          Re: CfV: S>F and F>S Bernd Paysan <bernd.paysan@gmx.de> - 2012-08-04 21:47 +0200
      Re: CfV: S>F and F>S Krishna Myneni <krishna.myneni@ccreweb.org> - 2012-08-04 05:42 -0700

csiph-web