Post by HÆ°ng GiaCould 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.
Post by HÆ°ng GiaI 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