[Oberon] real math

Felix Friedrich felix.friedrich at inf.ethz.ch
Thu Nov 13 12:38:21 CET 2014


On my pc, compiling

float r = float(480) / 100 * 100;
std::cout << int(r*1000000) << "\n";

using gcc 4.7.1. and g++.exe -Weffc++ -pedantic-errors -pedantic 
-std=c++11 -Wextra -Wall  -c

produces output
480000030


> (*
>
>    To not confuse everyone here is my source code and what it outputs.
>    I am using aos.linux revision 5730 on debian wheezy on AMD64
>    Tested the same source on gcc and result was 480.
>    Zdenek
>
>    test2.test ~    outputs:  480000032
>
>    SystemTools.Free test2 ~
>
> *)
>
> MODULE test2;
>   IMPORT out:=KernelLog;
>
> PROCEDURE test*();
> VAR
>   r : REAL;
> BEGIN
>   r := 480 / 100 * 100;
>   out.Int(ENTIER(r * 1000000),0); out.Ln;
> END test;
>
> END test2.
>
>
>
>
>
>
>
>
> On Tue, Nov 11, 2014 at 04:12:01PM +0100, Jörg wrote:
>> Hi all
>>
>>   
>>
>> As neither myself nor Yaroslav had the result Zdenek had, we should ask:
>>
>> What Oberon system on what platform are you using, Zdenek?
>>
>>   
>>
>> br
>>
>> Jörg
>>
>>   
>>
>>   
>>
>> From: Yaroslav Romanchenko [mailto:tobject at bk.ru]
>> Sent: Dienstag, 11. November 2014 15:50
>> To: ETH Oberon and related systems
>> Subject: Re: [Oberon] real math
>>
>>   
>>
>>
>> How many right suggestions. But... anyway something wrong with real math in Oberon implementation, because same example in BlackBox returns yet another result expected by Zdenek.
>>
>> Code:
>>
>> MODULE M1;
>>
>> IMPORT
>> StdLog;
>>
>> PROCEDURE Do*;
>> VAR
>> r: REAL;
>> BEGIN
>> r := 480 / 100 * 100;
>> StdLog.Int(ENTIER(r * 1000000));
>> StdLog.Ln;
>> END Do;
>>
>> BEGIN
>> END M1.
>>
>> Output:
>>
>> 480000000
>>
>> Same result as BlackBox returned in commercial Embarcadero RAD Studio using type corresponding single type.
>>
>> ---
>> Cheers, SAGE
>> http://sage.com.ua/
>>
>
>
>> --
>> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
>> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon




More information about the Oberon mailing list