• OBNC Out.Real

    From =?UTF-8?B?SMawbmcgR2lh?=@21:1/5 to All on Thu Mar 5 23:48:22 2020
    Could you adjust the behavior of it to print normal floating point number instead of scientific notation? If it's the your design could you provide a way to print floating point number in the normal format? I can't found any procedure to it. I tried to
    use your ext library to convert real to string but it didn't work. The procedure take three parameters and not suitable to use like what I desire:

    Out.String(extConvert.RealToString(Math.sqrt(2)));

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Guy T.@21:1/5 to All on Sat Mar 7 04:36:25 2020
    On Friday, March 6, 2020 at 2:48:22 AM UTC-5, Hưng Gia wrote:
    Could you adjust the behavior of it to print normal floating point number instead of scientific notation? If it's the your design could you provide a way to print floating point number in the normal format? I can't found any procedure to it. I tried to
    use your ext library to convert real to string but it didn't work. The procedure take three parameters and not suitable to use like what I desire:

    Out.String(extConvert.RealToString(Math.sqrt(2)));

    Hello Hưng Gia,

    Modifying Out.Real is not a good idea as this module is expected to supply its procedure in the way they are. It would brake many existing piece of code. Better extract some lines of code from an existing module and modify it a bit to be like you desire.


    Cheers

    Guy T.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From miasap@21:1/5 to All on Sat Mar 7 19:59:07 2020
    On 2020-03-06 08:48, Hưng Gia wrote:
    Could you adjust the behavior of it to print normal floating point
    number instead of scientific notation? If it's the your design could
    you provide a way to print floating point number in the normal
    format? I can't found any procedure to it.

    As mentioned by Guy T, it's better to define a new procedure. The Out
    module implements the procedure Real according to the specification in
    "The Oakwood Guidelines for Oberon-2 Compiler Developers."

    Below is an example of how you can interface to the C function printf
    (see also the manual page for the obnc command).

    MODULE Print;

    (*implemented in C*)

    PROCEDURE Real*(x: REAL);
    END Real;

    END Print.


    Print.c:

    #include ".obnc/Print.h"
    #include <stdio.h>

    void Print__Real_(OBNC_REAL x)
    {
    printf("%f", x);
    }


    void Print__Init(void)
    {
    }


    MODULE PrintTest;

    IMPORT Out, Print;

    BEGIN
    Print.Real(3.1415926535);
    Out.Ln
    END PrintTest.

    I tried to use your ext library to convert real to string but it
    didn't work. The procedure take three parameters and not suitable to
    use like what I desire >
    Out.String(extConvert.RealToString(Math.sqrt(2)));

    In Oberon a procedure can only return scalar values. That's why
    RealToString is defined the way it is. Also, the procedure uses the same
    format as Out.Real.


    -- Karl

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)