Check_Item Is Always Equal To 0 When 2^32
Matthew Newton
mcn4 at leicester.ac.uk
Thu Oct 24 14:28:19 CEST 2013
On Thu, Oct 24, 2013 at 11:35:30AM +0000, Russell Mike wrote:
> > I can't make it any clearer than that.
>
> thank you very very much, it is great explanation. Your response made
> many things very clearer. But did not work for me still. Perhaps my formula
> is wrong. Kindly help one more step further. Honestly, i have tried very
> hard, working on it for some weeks now without results. i.e. i want to set
> 6GB limit.
>
> total bytes in 6GB = 805306368
> total bytes in 4GB = 536870912
Not sure where you got these from.
6GB = 6 * 1024 * 1024 * 1024 = 4 * 1024^3 = 6442450944
6GB in binary is
0000000000000000000000000000000110000000000000000000000000000000
3210987654321098765432109876543210987654321098765432109876543210
6 5 4 3 2 1 0
So the lower 32 bits are:
10000000000000000000000000000000
and the upper 32 bits are:
00000000000000000000000000000001
The lower bits can be found by bitwise AND with (2^32)-1 (i.e. 32
ones):
$ python
>>> 6*(1024**3) & ((2**32)-1)
2147483648
The upper 32 bits by shifting right by 32 bits:
>>> 6*(1024**3) >> 32
1
So you want
> i put 536870912 in ChilliSpot-Max-Input-Octets
this should be 2147483648;
> i put 268435456 in ChilliSpot-Max-Input-Gigawords
This should be 1.
To confirm the numbers are correct, left-shift the gigawords by 32
bits, then add the octets. Should come back to the original value:
>>> (1<<32) + 2147483648
6442450944
>>> 6*(1024**3)
6442450944
Matthew
--
Matthew Newton, Ph.D. <mcn4 at le.ac.uk>
Systems Specialist, Infrastructure Services,
I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom
For IT help contact helpdesk extn. 2253, <ithelp at le.ac.uk>
More information about the Freeradius-Users
mailing list