Article View: pl.comp.lang.c
Article #309668Re: Dlaczego ten test nie działa
From: szykcech
Date: Thu, 12 Apr 2018 12:30
Date: Thu, 12 Apr 2018 12:30
12 lines
2399 bytes
2399 bytes
> if((double(c_after - c_before)/CLOCKS_PER_SEC)>=1.0) Tu są 2 możliwe problemy: 1) c_after - c_before : ta wartość jest bardzo mała w porównaniu do CLOCKS_PER_SEC. Więc możliwe, że dzielenie jest < 1.0. Może jest to twój błąd, bo obie wartości ustawiasz w tej samej iteracji twojej pętli, wiec różnica jest bardzo mała (bo jest to zaledwie kilkanaście cykli). Wiec jak dzielisz to przez 1M to na pewno jest dużo mniej niż 1... 2) CLOCKS_PER_SEC może być int: ze strony: http://en.cppreference.com/w/cpp/chrono/c/CLOCKS_PER_SEC #define CLOCKS_PER_SEC /*implementation defined*/ POSIX defines CLOCKS_PER_SEC as one million, regardless of the actual precision of std::clock(). Dokładnie nie pamiętam zasad promocji typów w C++, ale dla pewności należało by również rzutować CLOCKS_PER_SEC do double if((double(c_after - c_before)/((double)CLOCKS_PER_SEC))>=1.0)
Technical Details
Message-ID:
<a27a3d1a-4e5e-45d9-ad77-e1e094f5cd04@googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!s52no1671932qtc.0!news-out.google.com!e12ni3121qtp.1!nntp.google.com!s52no1671924qtc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailReferences:
<11e93e39-69fc-4ee2-8886-9d077c8026fb@googlegroups.com> <2750bf86-40ef-4907-90fd-89e8542c0183@googlegroups.com> <a6c0bdb8-b0e7-4628-a7d6-bf79907261a2@googlegroups.com>Show Full Headers
Complete Article Headers
X-Received: by 10.237.32.196 with SMTP id 62mr500206qtb.22.1523536219583; Thu, 12 Apr 2018 05:30:19 -0700 (PDT) X-Received: by 10.31.173.80 with SMTP id w77mr74697vke.13.1523536219331; Thu, 12 Apr 2018 05:30:19 -0700 (PDT) Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.unit0.net!peer03.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!s52no1671932qtc.0!news-out.google.com!e12ni3121qtp.1!nntp.google.com!s52no1671924qtc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: pl.comp.lang.c Date: Thu, 12 Apr 2018 05:30:19 -0700 (PDT) In-Reply-To: <a6c0bdb8-b0e7-4628-a7d6-bf79907261a2@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=188.146.144.233; posting-account=pyti1AoAAAAf66c003TUy10QAAnMWaKw NNTP-Posting-Host: 188.146.144.233 References: <11e93e39-69fc-4ee2-8886-9d077c8026fb@googlegroups.com> <2750bf86-40ef-4907-90fd-89e8542c0183@googlegroups.com> <a6c0bdb8-b0e7-4628-a7d6-bf79907261a2@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <a27a3d1a-4e5e-45d9-ad77-e1e094f5cd04@googlegroups.com> Subject: Re: Dlaczego ten test nie działa From: szykcech@gmail.com Injection-Date: Thu, 12 Apr 2018 12:30:19 +0000 X-Received-Bytes: 2345 X-Received-Body-CRC: 3016001646 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit