ceil by integer math

This commit is contained in:
ed
2026-07-26 15:23:33 +00:00
parent e49f6cca17
commit 0f2040c383
6 changed files with 8 additions and 8 deletions
+2 -2
View File
@@ -626,7 +626,7 @@ class Gateway(object):
"st_atime": ts,
"st_mtime": ts,
"st_ctime": ts,
"st_blocks": int((sz + 511) / 512),
"st_blocks": -int(-sz // 512),
}
def stat_file(self, ts, sz):
@@ -638,7 +638,7 @@ class Gateway(object):
"st_atime": ts,
"st_mtime": ts,
"st_ctime": ts,
"st_blocks": int((sz + 511) / 512),
"st_blocks": -int(-sz // 512),
}
+2 -2
View File
@@ -398,7 +398,7 @@ class MTHash(object):
self.csz = chunksz
chunks = {}
nchunks = int(math.ceil(fsz / chunksz))
nchunks = -int(-fsz // chunksz)
for nch in range(nchunks):
self.work_q.put(nch)
@@ -725,7 +725,7 @@ def up2k_chunksize(filesize):
stepsize = 512 * 1024
while True:
for mul in [1, 2]:
nchunks = math.ceil(filesize * 1.0 / chunksize)
nchunks = -int(-filesize // chunksize)
if nchunks <= 256 or (chunksize >= 32 * 1024 * 1024 and nchunks <= 4096):
return chunksize
+1 -1
View File
@@ -318,7 +318,7 @@ class HttpSrv(object):
self.srvs.append(sck)
self.bound.add((ip, port))
self.nclimax = math.ceil(self.args.nc * 1.0 / nlisteners)
self.nclimax = -int(-self.args.nc // nlisteners)
Daemon(
self.thr_listen,
"httpsrv-n{}-listen-{}-{}".format(self.nid or "0", ip, port),
+1 -1
View File
@@ -5704,7 +5704,7 @@ def up2k_chunksize(filesize: int) -> int:
stepsize = 512 * 1024
while True:
for mul in [1, 2]:
nchunks = math.ceil(filesize * 1.0 / chunksize)
nchunks = -int(-filesize // chunksize)
if nchunks <= 256 or (chunksize >= 32 * 1024 * 1024 and nchunks <= 4096):
return chunksize
+1 -1
View File
@@ -1355,7 +1355,7 @@ class MTHash(object):
self.csz = chunksz
chunks: dict[int, tuple[str, int, int]] = {}
nchunks = int(math.ceil(fsz / chunksz))
nchunks = -int(-fsz // chunksz)
for nch in range(nchunks):
self.work_q.put(nch)
+1 -1
View File
@@ -26,7 +26,7 @@ def up2k_chunksize(filesize):
stepsize = 512 * 1024
while True:
for mul in [1, 2]:
nchunks = math.ceil(filesize * 1.0 / chunksize)
nchunks = -int(-filesize // chunksize)
if nchunks <= 256 or (chunksize >= 32 * 1024 * 1024 and nchunks <= 4096):
return chunksize