mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
fix: use builtin math instead of numpy for log2 and ceil to avoid overflow issues
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Declaration of `Integer` class.
|
||||
"""
|
||||
|
||||
import math
|
||||
from functools import partial
|
||||
from typing import Any
|
||||
|
||||
@@ -66,9 +67,9 @@ class Integer(BaseDataType):
|
||||
return 1
|
||||
|
||||
if value < 0:
|
||||
bits = int(np.ceil(np.log2(abs(value)))) + 1
|
||||
bits = int(math.ceil(math.log2(abs(value)))) + 1
|
||||
else:
|
||||
bits = int(np.ceil(np.log2(value + 1)))
|
||||
bits = int(math.ceil(math.log2(value + 1)))
|
||||
if force_signed:
|
||||
bits += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user