This is the problem behavior, not the desired behavior. It should do the right thing.
I wanted you to understand to avoid problems while we get the problem fixed.

--Chris

On 6/18/2015 06:44, Marek Gierliński wrote:
Thanks, Chris. I understand this now and will be more aware of type conversions in the future. Still, personally, I see this as an unexpected and potentially confusing thing.

Best regards,
Marek

On Thu, 18 Jun 2015 at 11:34 Chris Marshall <devel.chm...@gmail.com <mailto:devel.chm...@gmail.com>> wrote:

    Thanks for the additional report.

    The results reflect the typemap for conversions from perl scalars
    to PDL types which tries to avoid unnecessary type promotions
    (if you start with a byte value, you probably don't want the result
    as a 64bit int at the end).  PDL used to use doubles as the catch
    all type.  That doesn't work for 64bit integers since they are not
    representable as double (ieee with only a 52bit mantissa).

      floor(1.3)->floor(double) since 1.3 is not exact in float or int
      floor(1)->floor(byte) since 1 is an int < 256
      floor(1.0)->floor(float) since 1.0 is double or float and 1.0 is
    exact as float

    NOTE:  This is an explanation for what you have reported not a
    defense.

    Thanks for the investigations,
    Chris


    On 6/18/2015 03:59, Marek Gierliński wrote:
    Recently I have reported problems with using results of stats()
    as scalars. Today I found that another of my scripts, that used
    to work in older PDL versions, is failing. The problem is very
    similar, using one-element piddles in scalar context gives almost
    random results. Here it is:

    pdl> $x = floor(1.3)
    pdl> p $x
    1
    pdl> $x += 0.1
    pdl> p $x
    1.1

    pdl> $x = floor(1)
    pdl> p $x
    1
    pdl> $x += 0.1
    pdl> p $x
    1

    when taking floor() of an integer number, I cannot increment it
    afterwards. No problems when I take floor() of a non-integer. I
    think in this particular case the problem is with the type:

    pdl> $x = floor(1.1); p $x->info
    PDL: Double D []
    pdl> $x = floor(1); p $x->info
    PDL: Byte D []

    Suddenly, the type is changed and I suppose 'Byte' doesn't
    take +=0.1. This is a bit random, unexpected and unpredictable.
    In particular, there is inconsistency:

    pdl> $x = floor(1); p $x->info
    PDL: Byte D []
    pdl> $y = pdl(1); p $y->info
    PDL: Double D []

    Has something been changed in the recent months (or even years,
    as we used to use quite old version of PDL for years and only
    recently upgraded to 2.007) in the way types are converted and
    one-element piddles are treated in the scalar context? I'm just
    discovering more and more of my scripts doing weird things...

    Cheers,
    Marek


    
------------------------------------------------------------------------------


    _______________________________________________
    pdl-devel mailing list
    pdl-devel@lists.sourceforge.net  <mailto:pdl-devel@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/pdl-devel

    
------------------------------------------------------------------------------
    _______________________________________________
    pdl-devel mailing list
    pdl-devel@lists.sourceforge.net
    <mailto:pdl-devel@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/pdl-devel


------------------------------------------------------------------------------
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to