info-sather
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C_FLOAT New user question


From: Norbert Nemec
Subject: Re: C_FLOAT New user question
Date: Mon, 2 Oct 2000 23:31:37 +0200
User-agent: Mutt/1.0.1i

AFAIK, Sather tries to be IEEE... correct concerning floats. Strange 
that the conversion does not work.

On Mon, Oct 02, 2000 at 05:07:16PM +0000, Dave Simons wrote:
> Hello
> 
> Could anyone tell me what is going wrong here. I can't find anything in
> the doc.
> 
> 
> 
> SATHER FILE cfloat.sa
> 
> =====================
> 
> class MAIN is
>       main is
>               number:FLT := 1.0;
>               loop
>                       USING_SATHER::show_float(#(number));
>                       USING_C::show_float(#(number));
>                       number := number + 0.2;
>                       until!(number > 3.0);
>               end;
>       end;
> end;
> 
> class USING_SATHER is
>       show_float(sather_number:C_FLOAT) is
>               #OUT+"Number according to Sather: "+sather_number.flt+"\n";
>       end;
> end;
> 
> external C class USING_C is
>       show_float(c_number:C_FLOAT);
> end;
> 
> =====================
> 
> C FILE        cfloat.c
> 
> =====================
> 
> show_float(c_number) float c_number; {
> 
>       printf("Number according to C: %f\n\n", c_number);
> }
> 
> =====================
> 
> %>cc -c cfloat.c
> %>sacomp cfloat.sa cfloat.o -o cfloat
> %>./cfloat
> 
> Number according to Sather: 1
> Number according to C: 0.007813
> 
> Number according to Sather: 1.2
> Number according to C: 0.025000
> 
> Number according to Sather: 1.4
> Number according to C: 0.075000
> 
> Number according to Sather: 1.6
> Number according to C: 0.225000
> 
> Number according to Sather: 1.8
> Number according to C: 0.700001
> 
> Number according to Sather: 2
> Number according to C: 2.000002
> 
> Number according to Sather: 2.2
> Number according to C: 3.600003
> 
> Number according to Sather: 2.4
> Number according to C: 6.400006
> 
> Number according to Sather: 2.6
> Number according to C: 11.200014
> 
> Number according to Sather: 2.8
> Number according to C: 19.200031
> 
> 
> The problem only happens with floats. C_INT works perfectly.
> 
> And if I substitute normal FLT's for C_FLOAT's in the Sather
> file, I get exactly the same result. Is Sather overlooking a
> library or something?
> 
> Thanks in advance,
> 
> Dave.
> 
> 
> This message was sent by XFMail
> ----------------------------------

-- 
-- ______________________________________________________
-- JESUS CHRIST IS LORD!
--          To Him, even that machine here has to obey...
--
-- _________________________________Norbert "Nobbi" Nemec
-- Hindenburgstr. 44  ...  D-91054 Erlangen  ...  Germany
-- eMail: <address@hidden>   Tel: +49-(0)-9131-204180



reply via email to

[Prev in Thread] Current Thread [Next in Thread]