Re: [Nautilus-list] Tiny patch



On Mon, 2002-04-08 at 16:20, Darin Adler wrote:
> +	ram_size = (strtoul (temp_str, NULL, 10) + 1024) / 1000;
> 
> I'm sorry, the above calculation makes no sense to me. Add 1024 and then 
> divide by 1000? How could this possibly be more accurate? The old code 
> rounded to the nearest 1000. This code is close to "round up to the 
> nearest 1000" (that would be +999 /1000). Maybe that's what you're 
> looking to do? I know there's been a long thread about this, but I'd 
> like to understand it better.
> 
Effectively it's as follows
temp_str = /proc/meminfo#MemTotal + 1024Kb
Dividing by 1000 gives the Mb value with the following line checking if
the result is still >1000 then us Gb instead of Mb.
The current code adds 500 to round up but it's still WELL SHORT on lots
of different systems I've tried.

It's kind of "on crack" code but for ALL my searches etc. I've not found
a "correct" way to do it. Seems that the kernel only reports total
memory available for use in /proc/meminfo and there's no way to easily
find out what the kernel is holding back. A true figure would be Value
the Kernel has allocated + the value reported as /proc/meminfo#MemTotal.

> On the other hand, since the hardware view is a bit of a hidden, 
> marginal feature, I don't think we have to be super-careful about it, so 
> I wouldn't be too upset if you committed this. But I'm certain that 
> adding 1024 and then dividing by 1000 does not make sense.
> 
And it's "more accurate" on every system I tried the formula on. On my
PC I've 384. It was being reported as 383. On my laptop I've 256, this
was being reported as 255. On another machine here with 128 it was being
reported as 127. All these now report the correct figure.

If someone knows the "correct" way to get this figure, i.e. Not a
guesstimation, then I'll gladly give it a go.

> > 2)Display an icon in the sidebar when in the hardware view as opposed to
> > the blank icon that's there currently. Attached is the icon too.
> 
> Looks great.
> 
Better than a grey sqare at least :-).

-- 
_______________________________________
Glen Gray             Software Engineer
a n t e f a c t o     t: +353 1 8586006
www.antefacto.com     f: +353 1 8586014
181 Parnell Street - Dublin 1 - Ireland





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]