How to compare two floats?
Cathey, Jim
jcathey at ciena.com
Wed May 27 17:38:28 UTC 2015
Unless you need the enhance dynamic range abilities of
floating point, you shouldn't be using it at all. That's
just a general principle. Devcie temperatures are well
handled by fixed-point (integer) routines.
-- Jim
-----Original Message-----
From: busybox [mailto:busybox-bounces at busybox.net] On Behalf Of bifferos
Sent: Sunday, May 24, 2015 4:05 AM
To: Lauri Kasanen; busybox at busybox.net
Subject: Re: How to compare two floats?
Thanks for all the responses to this, it's given me some ideas.
regards,
Biff.
>________________________________
> From: Lauri Kasanen <curaga at operamail.com>
>To: busybox at busybox.net
>Sent: Sunday, 24 May 2015, 8:40
>Subject: Re: How to compare two floats?
>
>
>> On Saturday 23 May 2015 21:41:51 bifferos wrote:
>> > I'm trying to write a thermostat using busybox shell, however the only way I
>> > could think to compare two float temperatures (without adding awk) was to
>> > multiply them up in dc and then compare as integers. In the end I modified
>> > dc to add a comparison operator, which probably breaks the spirit of dc
>> > somewhat. I'm interested if I missed a trick somewhere. Is there another
>> > way to do this? Is this considered a heinous thing to do to dc?
>
>a - b
>
>Then you check if the sign is negative, using the shell's string ops.
>
>- Lauri
>
>--
>http://www.fastmail.com - Access all of your messages and folders
> wherever you are
>
>
>
>
>
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://lists.busybox.net/mailman/listinfo/busybox
>
>
>
_______________________________________________
busybox mailing list
busybox at busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list