On 25.07.2020 18:47, Rick McGuire wrote:
> Something to try. Switch the order of the two ::REQUIRES to see if the 
> problem goes away. It
> really does look like there's something that BSF4ooRexx is doing that causes 
> this behavior, but it
> is puzzling that it doesn't happen on other platforms.

Once both (BSF.CLS, rxmath) are required, no matter in which sequence, will 
cause the wrong result
to be returned by rxmath:

    #!/usr/bin/env rexx
    say "digits():" pp(digits())
    say "Before BSF is called:" rxcalcsqrt(129)
    say "now invoking BSF"
    -- call BSF.CLS
    say "digits():" pp(digits())
    say "After BSF is called:" rxcalcsqrt(129)
    say "digits():" pp(digits())
    say "---"
    parse version v
    say "Rexx version          :" pp(v)
    say "bsfVersion()          :" pp(bsfVersion())
    say ".bsf4rexx~version     :" pp(.bsf4rexx~version)
    say ".bsf4rexx~java.version;" pp(.bsf4rexx~java.version)

    ::requires BSF.CLS
    ::requires 'rxmath' LIBRARY

    ::routine pp
      return "["arg(1)"]"

will yield:

    rony@rony-linux:~/Dropbox/xfer/bsf4oorexx/tmp/ruurd$ rexx test4.rex
    digits(): [9]
    Before BSF is called: 1.10000000E+11
    now invoking BSF
    digits(): [9]
    After BSF is called: 1.10000000E+11
    digits(): [9]
    ---
    Rexx version          : [REXX-ooRexx_5.0.0(MT)_64-bit 6.05 3 May 2020]
    bsfVersion()          : [600.20181002 org/rexxla/bsf/engines/rexx 64-bit]
    .bsf4rexx~version     : [641.20200130]
    .bsf4rexx~java.version; [14.0.1]
    rony@rony-linux:~/Dropbox/xfer/bsf4oorexx/tmp/ruurd$

whereas requiring "rxmath" yields:  11.3578167, then immediately followed by a 
"call bsf.cls" will
yield the wrong value:1.10000000E+11.

---

Ruurd suggested using "readelf -a -W libjvm.so | grep sqrt".

Both, libjvm.so and librxmath.so, are using sqrt from glibc ("GLIBC_2.2.5"). 
However there are small
differences between the two:

    rony@rony-linux:~/Dropbox/xfer/bsf4oorexx/tmp/ruurd$ readelf -a -W 
/usr/lib/jvm/adoptopenjdk-14-hotspot-amd64/lib/server/libjvm.so | grep sqrt | 
grep -i glib
    00000000014f0288  0000008e00000007 R_X86_64_JUMP_SLOT     0000000000000000 
sqrt@GLIBC_2.2.5 + 0
    00000000014f0638  0000016e00000007 R_X86_64_JUMP_SLOT     0000000000000000 
sqrtf@GLIBC_2.2.5 + 0
       142: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sqrt@GLIBC_2.2.5 
(6)
       366: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND 
sqrtf@GLIBC_2.2.5 (6)
     56008: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UNDsqrt@@GLIBC_2.2.5
     56232: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND 
sqrtf@@GLIBC_2.2.5

    rony@rony-linux:~/Dropbox/xfer/bsf4oorexx/tmp/ruurd$ readelf -a -W 
/usr/lib/librxmath.so | grep sqrt | grep -i glib
    0000000000205128  0000001600000007 R_X86_64_JUMP_SLOT     0000000000000000 
sqrt@GLIBC_2.2.5 + 0
        22: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sqrt@GLIBC_2.2.5 
(3)
       130: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sqrt@@GLIBC_2.2.5
    rony@rony-linux:~/Dropbox/xfer/bsf4oorexx/tmp/ruurd$

---rony


>
> On Sat, Jul 25, 2020 at 12:29 PM Rony G. Flatscher <rony.flatsc...@wu.ac.at
> <mailto:rony.flatsc...@wu.ac.at>> wrote:
>
>     To clarify: to the best of my knowledge BSF4ooRexx does nothing that 
> would explain this weird
>     behaviour on Linux. (It works as expected on Windows and MacOS.)
>
>     ---rony
>
>     P.S.: Ruurd came up with the idea that maybe the Java virtual machine 
> that gets loaded may cause
>     this effect on Linux (both, librxmath.so and libjvm.so, use sqrt from the 
> runtime). Even if
>     so, this
>     awkward behaviour in Rexx should not be a side-effect of using any other 
> library together with
>     Rexx.
>
>
>     On 25.07.2020 12:12, Ruurd Idenburg wrote:
>     > Running the attached script "rxmath.rex"  will yield a weird result on 
> my Linux (Mint 19.3,
>     which
>     > is based on Ubuntu 18.04) when the RxCalcSqrt function is called from 
> the RXBSF.REX for a
>     > non-perfect square (129).
>     >
>     > The code in RXBSF.REX does only ::REQUIRE  BSF.CLS without using any of 
> its possibilities
>     (unless
>     > some lines are uncommented) but in turn requires the Java library 
> "libjvm.so"
>     >
>     > It looks like the ::REQUIRE causes the sqrt function to produce a 
> different outcome of the
>     > resulting floating point number.
>     >
>     > When I run the code on a Windows 10 machine, the results from RXBSF.REX 
> are correct. Rony
>     Flatcher
>     > ran the scripts on Darwin (MacOS) and there the results were correct 
> too.
>     >
>     > I included the pure Rexx ::ROUTINE my_sqrt (more or less copied from 
> Walter Pachl's rxm.cls on
>     > Rosetta.org) to verify that that works OK.
>     >
>     > Also before calling RXBSF.REX from rxmath.rex and after returning from 
> RXBSF.REX the results of
>     > the RxMath rxCalcSqrt function are OK again.
>     >
>     > Seems to me that RxMath should not be impacted by another ::REQUIRE (if 
> that is the case??).
>     >
>     > Anybody with more system experience has some thoughts on how to tackle 
> this?
>     >
>     > Cheers,
>     >
>     > Ruurd
>     >
>     > P.S.
>     >
>     > I have now switched to the use of Walter Pachl's  very nice package 
> (thanks Walter) that you can
>     > find here:
>     >
>     > <http://rosettacode.org/wiki/Trigonometric_functions#ooRexx>
>

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

Reply via email to