[PATCH 8/9] Negative numbers added for sreal class.

Richard Biener richard.guenther@gmail.com
Fri Nov 21 15:46:00 GMT 2014


On Fri, Nov 21, 2014 at 3:39 PM, Martin Liška <mliska@suse.cz> wrote:

> Hello.
>
> Ok, this is simplified, one can use sreal a = 12345 and it works ;)
>
>> that's a  new API, right?  There is no max () and I think that using
>> LONG_MIN here is asking for trouble (host dependence).  The
>> comment in the file says the max should be
>> sreal (SREAL_MAX_SIG, SREAL_MAX_EXP) and the min
>> sreal (-SREAL_MAX_SIG, SREAL_MAX_EXP)?
>>
>
> Sure, sreal can store much bigger(smaller) numbers :)
>
>> Where do you need sreal::to_double?  The host shouldn't perform
>> double calculations so it can be only for dumping?  In which case
>> the user should have used sreal::dump (), maybe with extra
>> arguments.
>>
>
> That new function was request from Honza, only for debugging purpose.
> I agree that dump should this kind of job.
>
> If no other problem, I will run tests once more and commit it.
> Thanks,
> Martin

-#define SREAL_MAX_EXP (INT_MAX / 4)
+#define SREAL_MAX_EXP (INT_MAX / 8)

this change doesn't look necessary anymore?

Btw, it's also odd that...

 #define SREAL_PART_BITS 32
...
 #define SREAL_MIN_SIG ((uint64_t) 1 << (SREAL_PART_BITS - 1))
 #define SREAL_MAX_SIG (((uint64_t) 1 << SREAL_PART_BITS) - 1)

thus all m_sig values fit in 32bits but we still use a uint64_t m_sig ...
(the implementation uses 64bit for internal computations, but still
the storage is wasteful?)

Of course the way normalize() works requires that storage to be
64bits to store unnormalized values.

I'd say ok with the SREAL_MAX_EXP change reverted.

Thanks,
Richard.


>
>> Otherwise looks good to me and sorry for not noticing the above
>> earlier.
>>
>> Thanks,
>> Richard.
>>
>>> Thanks,
>>> Martin
>>>
>>>
>>>>>    };
>>>>>
>>>>>    extern void debug (sreal &ref);
>>>>> @@ -76,12 +133,12 @@ inline sreal &operator+= (sreal &a, const sreal
>>>>> &b)
>>>>>
>>>>>    inline sreal &operator-= (sreal &a, const sreal &b)
>>>>>    {
>>>>> -return a = a - b;
>>>>> +  return a = a - b;
>>>>>    }
>>>>>
>>>>>    inline sreal &operator/= (sreal &a, const sreal &b)
>>>>>    {
>>>>> -return a = a / b;
>>>>> +  return a = a / b;
>>>>>    }
>>>>>
>>>>>    inline sreal &operator*= (sreal &a, const sreal &b)
>>>>> --
>>>>> 2.1.2
>>>>>
>>>>>
>>>
>



More information about the Gcc-patches mailing list