[clean-list] questions from a beginner

Markó Csaba marko_csaba at mail.tvnet.hu
Mon Apr 30 16:11:15 MEST 2007


Ok, I see this "Real" problem too hard for me now. I can't deal with 
low-level problems,
while I don't know the basics.
Thanks for the answers! Maybe, I'm going to ask other things while I'm 
learning Clean.

Markó Csaba


Arjen wrote:
> Hi,
>
> The 32 bit code generator transfers Reals between registers, which are
> 80 bits, and memory locations, which are 64 bits. Whenever Reals get
> stored (unboxed on the B-stack or boxed on the A-stack/heap), they get
> converted to 64 bit floating point numbers.
>
> Calculations on Reals are performed by a mix of 80 bit precision
> operations and 64 bit precision loads and stores. Often these conversion
> to 64 bit precision are not generated because the machine has enough
> registers to keep all intermediate results.
>
> This means that calculations on Reals can yield different result
> depending on the register spills of the code generator. Results can also
> change because of gaining or losing strictness in your expressions,
> because only a strict and unboxed Real can stay in a register.
>
> 64 bit Clean uses SSE2 and has no such precision/conversion issues.
>
> kind regards,
> 	Arjen
>
> lethevert wrote:
>   
>> Hello,
>>
>>     
>>>> *My first solution try:
>>>>    smallestRealv2 = until (\x = x/10.0 == 0.0 ) (\x = x/10.0) 1.0
>>>>    Start = smallestRealv2
>>>> It prints: 0
>>>>         
>>> This one I'm not sure about. Your solution seems correct, and when I try
>>> your solution in Haskell I do get the last number in that list. Not sure
>>> what's happening here.
>>>
>>>       
>> I found a strange behaviour of a related clean program.
>> I wrote a test code below.
>>
>> =======================================================
>> Start = let n1 = 9.88131291682493E-324 / 10.0
>>             n2 = 9.88131291682493E-324 / 10.0
>>         in (n1 <> 0.0, n2 <> 0.0, n2)
>> =======================================================
>>
>> Apparently the variable n1 and n2 have exactly the same value,
>> but it produces: (True, False, 0)
>>
>> I checked the intermediate abc code and find that
>> the code for n1 is
>> =======================================================
>>     pushR 10.0
>>     pushR 9.88131291682493E-324
>>     divR
>>     pushR 0.0
>>         ...
>>     eqR
>>     notB
>> =======================================================
>> and then I changed it to
>> =======================================================
>>     pushR 10.0
>>     pushR 9.88131291682493E-324
>>     divR
>>     buildR_b 0
>>     pop_b 2
>>     pushR_a 0
>>     pop_a 1
>>     pushR 0.0
>>         ...
>>     eqR
>>     notB
>> =======================================================
>> and I got: (False, False, 0)
>>
>> It seams that the A-stack has some effect on a Real number value,
>> but I have no further idea about it.
>>
>> I uses Clean 2.2 for Linux 32bit version.
>>
>>     


More information about the clean-list mailing list