From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Konrad Anton <konrad.anton@awinia.de>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH] cangen: use long long in time computation for -g to support >2.1s
Date: Thu, 07 Feb 2013 13:57:07 +0100 [thread overview]
Message-ID: <5113A4A3.70003@pengutronix.de> (raw)
In-Reply-To: <51138A44.5090306@awinia.de>
[-- Attachment #1: Type: text/plain, Size: 1646 bytes --]
On 02/07/2013 12:04 PM, Konrad Anton wrote:
> Hello,
>
> On 07.02.2013 11:41, Marc Kleine-Budde wrote:
>> we're a bit oldschool and discuss the code on the
>> linux-can@vger.kernel.org mailinglist. Feel free to subscribe.
>
> Can you please put that information on the Gitorious page for the next
> casual committer?
>
>
>>> ts.tv_sec = gap / 1000;
>>> - ts.tv_nsec = ((int)(gap * 1000000)) % 1000000000;
>>> + ts.tv_nsec = (long)(((long long)(gap * 1000000)) % 1000000000ll);
>>
>> What's going on here exactly?
>>
>> gap is a double - Will it be converted into an int before multiplication
>> with 1000000? IIRC there is a difference between "gap * 1000000" and
>> "gap * 1000000.0". In the latter the multiplication is done in floating
>> point, because of the ".0".
>
> gap is a double.
> (gap * 1000000) will cause 1000000 to be converted to intermediate temp1
> of type double,
> temp1 will be truncated to long long temp2, losing its decimals,
> temp2 will be moduloed by 1000000000ll in a long-long mod operation,
> giving temp3.
> temp3 will be truncated to as many bits as long has, and stored in long
> tv_nsec.
>
> I think it is safe.
Thanks for the details. Looks good. Can I add your Signed-off-by[1] to
the patch?
Marc
[1]
http://lxr.free-electrons.com/source/Documentation/SubmittingPatches#L298
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
next prev parent reply other threads:[~2013-02-07 12:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-07 10:17 [Gitorious] Activity: konrada updated merge request for k Gitorious
2013-02-07 10:38 ` [PATCH] cangen: use long long in time computation for -g to support >2.1s Marc Kleine-Budde
2013-02-07 10:41 ` Marc Kleine-Budde
2013-02-07 11:04 ` Konrad Anton
2013-02-07 12:57 ` Marc Kleine-Budde [this message]
[not found] ` <5113A525.2030208@awinia.de>
2013-02-07 13:02 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5113A4A3.70003@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=konrad.anton@awinia.de \
--cc=linux-can@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.