mailing list of musl libc
 help / color / mirror / code / Atom feed
* [math] The math library have some bug for ceil,floor,round functioin, in arm mode
@ 2014-10-14  2:17 bobodog
  2014-10-14  2:42 ` Rich Felker
  0 siblings, 1 reply; 11+ messages in thread
From: bobodog @ 2014-10-14  2:17 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 6282 bytes --]

HI,ALL
         We use musl in arm process, but found some bugs about math library,  x86 process is ok!


         Here the test result:
         1) In ARM mode: (the result is wrong)


[    9.235921][kernel/command/cmd-test.c:44] ceil(-0.125000) = 0.000000, floor(-0.125000) = -1.000000, round(-0.125000) = 0.000000
[    9.238523][kernel/command/cmd-test.c:44] ceil(-0.250000) = 0.000000, floor(-0.250000) = -1.000000, round(-0.250000) = 0.000000
[    9.239770][kernel/command/cmd-test.c:44] ceil(-0.375000) = 0.000000, floor(-0.375000) = -1.000000, round(-0.375000) = 0.000000
[    9.241081][kernel/command/cmd-test.c:44] ceil(-0.500000) = 0.000000, floor(-0.500000) = -1.000000, round(-0.500000) = -0.500000
[    9.242361][kernel/command/cmd-test.c:44] ceil(-0.625000) = 0.000000, floor(-0.625000) = -1.000000, round(-0.625000) = -0.625000
[    9.243637][kernel/command/cmd-test.c:44] ceil(-0.750000) = 0.000000, floor(-0.750000) = -1.000000, round(-0.750000) = -0.750000
[    9.244879][kernel/command/cmd-test.c:44] ceil(-0.875000) = 0.000000, floor(-0.875000) = -1.000000, round(-0.875000) = -0.875000
[    9.246183][kernel/command/cmd-test.c:44] ceil(-1.000000) = -1.000000, floor(-1.000000) = -1.000000, round(-1.000000) = -1.000000
[    9.247457][kernel/command/cmd-test.c:44] ceil(-1.125000) = -1.125000, floor(-1.125000) = -1.125000, round(-1.125000) = -1.125000
[    9.248333][kernel/command/cmd-test.c:44] ceil(-1.250000) = -1.250000, floor(-1.250000) = -1.250000, round(-1.250000) = -1.250000
[    9.249303][kernel/command/cmd-test.c:44] ceil(-1.375000) = -1.375000, floor(-1.375000) = -1.375000, round(-1.375000) = -1.375000
[    9.250456][kernel/command/cmd-test.c:44] ceil(-1.500000) = -1.500000, floor(-1.500000) = -1.500000, round(-1.500000) = -1.500000
[    9.251730][kernel/command/cmd-test.c:44] ceil(-1.625000) = -1.625000, floor(-1.625000) = -1.625000, round(-1.625000) = -1.625000
[    9.252975][kernel/command/cmd-test.c:44] ceil(-1.750000) = -1.750000, floor(-1.750000) = -1.750000, round(-1.750000) = -1.750000
[    9.254272][kernel/command/cmd-test.c:44] ceil(-1.875000) = -1.875000, floor(-1.875000) = -1.875000, round(-1.875000) = -1.875000
[    9.255563][kernel/command/cmd-test.c:44] ceil(-2.000000) = -2.000000, floor(-2.000000) = -2.000000, round(-2.000000) = -2.000000
[    9.256813][kernel/command/cmd-test.c:44] ceil(-2.125000) = -2.125000, floor(-2.125000) = -2.125000, round(-2.125000) = -2.125000
[    9.257610][kernel/command/cmd-test.c:44] ceil(-2.250000) = -2.250000, floor(-2.250000) = -2.250000, round(-2.250000) = -2.250000
[    9.258029][kernel/command/cmd-test.c:44] ceil(-2.375000) = -2.375000, floor(-2.375000) = -2.375000, round(-2.375000) = -2.375000
[    9.259500][kernel/command/cmd-test.c:44] ceil(-2.500000) = -2.500000, floor(-2.500000) = -2.500000, round(-2.500000) = -2.500000
‍

         2) In X86 mode: (the result is correct)
[    3.790000][kernel/command/cmd-test.c:44] ceil(-0.125000) = 0.000000, floor(-0.125000) = -1.000000, round(-0.125000) = 0.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-0.250000) = 0.000000, floor(-0.250000) = -1.000000, round(-0.250000) = 0.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-0.375000) = 0.000000, floor(-0.375000) = -1.000000, round(-0.375000) = 0.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-0.500000) = 0.000000, floor(-0.500000) = -1.000000, round(-0.500000) = -1.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-0.625000) = 0.000000, floor(-0.625000) = -1.000000, round(-0.625000) = -1.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-0.750000) = 0.000000, floor(-0.750000) = -1.000000, round(-0.750000) = -1.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-0.875000) = 0.000000, floor(-0.875000) = -1.000000, round(-0.875000) = -1.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-1.000000) = -1.000000, floor(-1.000000) = -1.000000, round(-1.000000) = -1.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-1.125000) = -1.000000, floor(-1.125000) = -2.000000, round(-1.125000) = -1.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-1.250000) = -1.000000, floor(-1.250000) = -2.000000, round(-1.250000) = -1.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-1.375000) = -1.000000, floor(-1.375000) = -2.000000, round(-1.375000) = -1.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-1.500000) = -1.000000, floor(-1.500000) = -2.000000, round(-1.500000) = -2.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-1.625000) = -1.000000, floor(-1.625000) = -2.000000, round(-1.625000) = -2.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-1.750000) = -1.000000, floor(-1.750000) = -2.000000, round(-1.750000) = -2.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-1.875000) = -1.000000, floor(-1.875000) = -2.000000, round(-1.875000) = -2.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-2.000000) = -2.000000, floor(-2.000000) = -2.000000, round(-2.000000) = -2.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-2.125000) = -2.000000, floor(-2.125000) = -3.000000, round(-2.125000) = -2.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-2.250000) = -2.000000, floor(-2.250000) = -3.000000, round(-2.250000) = -2.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-2.375000) = -2.000000, floor(-2.375000) = -3.000000, round(-2.375000) = -2.000000
[    3.790000][kernel/command/cmd-test.c:44] ceil(-2.500000) = -2.000000, floor(-2.500000) = -3.000000, round(-2.500000) = -3.000000


        The test code:
int test(int argc, char ** argv)
{
	double n = 0.0;
	int i;


	for(i = 0; i < 20; i++)
	{
		n = n - 0.125;
		printf("ceil(%f) = %f, floor(%f) = %f, round(%f) = %f\n", n, ceil(n), n, floor(n), n, round(n));
	}


	return 0;
}‍


       May be rint trunc have same problem. this is supper big bug!!!


------------------
____________________________
蒋建军                            
深圳市九鼎创展科技有限公司
地址:深圳市宝安区西乡街道宝源路宝安互联网产业基地A区7栋301
邮编:518101
手机:18665386306
电邮:8192542@qq.com
网站:http://www.9tripod.com

论坛:http://xboot.org

[-- Attachment #2: Type: text/html, Size: 10182 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-10-14 15:33 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-14  2:17 [math] The math library have some bug for ceil,floor,round functioin, in arm mode bobodog
2014-10-14  2:42 ` Rich Felker
2014-10-14  2:51   ` 回复: [musl] [math] The math library have some bug forceil,floor,round " bobodog
2014-10-14  3:03     ` Rich Felker
2014-10-14  4:11       ` 回复: [musl] 回复: [musl ] [math] The math library have some bugforceil,floor,round " bobodog
2014-10-14  6:26         ` RE:[musl ] [math] I Found math library's bug in ceil, floor, round functions, Using arm toolchains bobodog
2014-10-14  6:43           ` [BUG][math]build musl with optimizing flags, some math functions are broken bobodog
     [not found]             ` <tencent_07C7708762DD414A5A757808@qq.com>
2014-10-14 15:12               ` RE:[BUG][math]build " Rich Felker
2014-10-14 15:33               ` RE???[BUG][math]build " Szabolcs Nagy
2014-10-14  8:06           ` RE???[musl ] [math] I Found math library's bug in ceil, floor, round functions, Using arm toolchains Szabolcs Nagy
2014-10-14  3:04     ` 回复: [musl] The math library have some bug forceil,floor,round functioin, in arm mode bobodog

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).