linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Anton <konrad.anton@awinia.de>
To: 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 12:04:36 +0100	[thread overview]
Message-ID: <51138A44.5090306@awinia.de> (raw)
In-Reply-To: <511384F4.703@pengutronix.de>

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.

--Konrad



-- 
------------------------------------------------------------------------
Konrad Anton
awinia gmbh, Software Consulting and Development
Max-Josef-Metzger-Str. 2, D-79111 Freiburg
Tel. +49 761 52 07 449 19
Fax. +49 761 52 07 449 10
EMail: konrad.anton@awinia.de
Handelsregister Nr.: HRB 706296, eingetragen beim Amtsgericht Freiburg
USt.-IdNr.: DE 275018159
Geschäftsführer: Marc Gossweiler, Bernd Wiedle
------------------------------------------------------------------------

  reply	other threads:[~2013-02-07 11:11 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 [this message]
2013-02-07 12:57       ` Marc Kleine-Budde
     [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=51138A44.5090306@awinia.de \
    --to=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 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).