# eval / toliteral safety question

H. Peter Anvin (hpa@trantor.zytor.com)
Tue, 11 Jun 1996 19:37:32 PDT

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    Followup to:  <199606111344.JAA09446@rabbit.INS.CWRU.Edu>
    By author:    "Seth I. Rich" <sir@po.cwru.edu>
    In newsgroup: local.moo
    >
    > Is there EVER a circumstace where
    >   eval("return " + toliteral(x) + ";")[2]
    > would not equal x?  Can anyone think of a situation in which this would
    > represent an unsafe operation?  I've been trying to think of a value fo=
    r
    > x for which this expression could have side effects, but I haven't come
    > up with anything yet, and I suspect I won't.
    >=20

    Yes.  toliteral() may induce a (small) rounding error when used on
    floating-point numbers.

    	-hpa
    --=20
    PGP public key available - finger hpa@zytor.com
    "The earth is but one country, and mankind its citizens."  --  Bah=E1'u'l=
    l=E1h
    Just Say No to Morden * Save Babylon 5: http://www.babylon5.com/cmp/suppo=
    rt/
    The cat is out of the bag - Linux 2.0 is available!