From mboxrd@z Thu Jan 1 00:00:00 1970 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-reply-to: Your message of "Tue, 29 Jan 2013 17:44:16 EST." References: <87c109280f2fc2bdaa0c68867f849daf@hamnavoe.com> Date: Wed, 30 Jan 2013 14:18:45 -0800 From: Bakul Shah Message-Id: <20130130221845.CB4BAB82A@mail.bitblocks.com> Subject: Re: [9fans] emulated fp on arm Topicbox-Message-UUID: 11d87b46-ead8-11e9-9d60-3106f5b1d025 On Tue, 29 Jan 2013 17:44:16 EST erik quanstrom wrote: > On Tue Jan 29 17:12:15 EST 2013, 9fans@hamnavoe.com wrote: > > > i'm not a fp expert, but i think there are two problems here. first > > > it is bad form to generate -0 in the emulator, even if it is technically > > > correct, and second, -0 is defined to be equal to 0 by the spec, so > > > -0 == 0 should always be true. > > > > I think you're right on the second point (I haven't read the IEEE spec > > lately, just looked at wikipedia), and wrong on the first. IEEE fp > > definitely allows for positive and negative zero, so the emulator should > > be generating them when the spec calls for them to do so. > > you might be right about the first point, but i'm really having a hard > time sorting this out. i don't have the standard, and it's $85. > this wiki page says there are some rules funny rules for addition/subtraction > : > http://en.wikipedia.org/wiki/Signed_zero#Arithmetic > > here's what i have with the as-is fpi > > ; for(i in ocilla ladd kw)cpu -h $i -c /tmp/awktest > Xeon -1 + 1 = 0 cmp 0 ok; cmp -0 ok > 1 + -1 = 0 cmp 0 ok; cmp -0 ok > Atom -1 + 1 = 0 cmp 0 ok; cmp -0 ok > 1 + -1 = 0 cmp 0 ok; cmp -0 ok > ARM -1 + 1 = -0 cmp 0 fail; cmp -0 fail > 1 + -1 = 0 cmp 0 ok; cmp -0 ok > ; and gcc/amd64 + gawk > -1 + 1 = 0 cmp 0 ok; cmp -0 ok As ieee754 (1985): When the sum of two operands with opposite signs (or the difference of two operands with like signs) is exactly zero, the sign of that sum (or difference) shall be + in all rounding modes except round toward -INFINITY, in which mode that sign shall be -.