From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Michal Schmidt <xschmi00@stud.feec.vutbr.cz>
Cc: linux-pm@lists.osdl.org, Pavel Machek <pavel@ucw.cz>,
linux-kernel@vger.kernel.org
Subject: Re: [linux-pm] [PATCH] swsusp: simpler calculation of number of pages in PBE list
Date: Fri, 29 Jul 2005 23:53:38 +0200 [thread overview]
Message-ID: <200507292353.39282.rjw@sisk.pl> (raw)
In-Reply-To: <42EA9C38.90905@stud.feec.vutbr.cz>
On Friday, 29 of July 2005 23:14, Michal Schmidt wrote:
> Rafael J. Wysocki wrote:
> > On Friday, 29 of July 2005 21:46, Michal Schmidt wrote:
> >
> >>The function calc_nr uses an iterative algorithm to calculate the number
> >>of pages needed for the image and the pagedir. Exactly the same result
> >>can be obtained with a one-line expression.
> >
> >
> > Could you please post the proof?
> >
> > Rafael
>
> OK, attached is a proof-by-brute-force program. It compares the results
> of the original function and the simplified one.
>
> This is its output:
>
> $ ./calc_nr2
> checked 0 ...
> checked 100000000 ...
> checked 200000000 ...
> checked 300000000 ...
> checked 400000000 ...
> checked 500000000 ...
> checked 600000000 ...
> checked 700000000 ...
> checked 800000000 ...
> checked 900000000 ...
> checked 1000000000 ...
> checked 1100000000 ...
> checked 1200000000 ...
> checked 1300000000 ...
> checked 1400000000 ...
> checked 1500000000 ...
> checked 1600000000 ...
> checked 1700000000 ...
> checked 1800000000 ...
> checked 1900000000 ...
> checked 2000000000 ...
> checked 2100000000 ...
> First difference at 2130706433: -2147483646 x -2147483647
>
> It means that the two functions give the same results for sensible
> values of the input argument.
> They results only differ when they overflow into negative values. At
> this point both of the results are useless.
Thanks, fine. :-)
Greets,
Rafael
--
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
-- Lewis Carroll "Alice's Adventures in Wonderland"
next prev parent reply other threads:[~2005-07-29 21:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-29 19:46 [PATCH] swsusp: simpler calculation of number of pages in PBE list Michal Schmidt
2005-07-29 20:43 ` [linux-pm] " Rafael J. Wysocki
2005-07-29 21:14 ` Michal Schmidt
2005-07-29 21:53 ` Rafael J. Wysocki [this message]
2005-07-30 1:35 ` Alan Stern
2005-07-30 13:16 ` Rafael J. Wysocki
2005-07-30 13:13 ` Pavel Machek
2005-07-30 13:32 ` Rafael J. Wysocki
2005-07-30 14:37 ` Alan Stern
2005-07-30 13:20 ` Pavel Machek
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=200507292353.39282.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.osdl.org \
--cc=pavel@ucw.cz \
--cc=xschmi00@stud.feec.vutbr.cz \
/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