Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big decimal methods for num types.2 #1309

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chiselFrontend/src/main/scala/chisel3/Bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ package experimental {
def binaryPoint: BinaryPoint

/** Return the [[Double]] value of this instance if it is a Literal
* @note this method may return throw an exception if the literal value won't fit in a Double
* @note this method may throw an exception if the literal value won't fit in a Double
*/
def litToDoubleOption: Option[Double] = {
litOption match {
Expand All @@ -1201,7 +1201,7 @@ package experimental {
def litToDouble: Double = litToDoubleOption.get

/** Return the [[BigDecimal]] value of this instance if it is a Literal
* @note this method may return throw an exception if the literal value won't fit in a BigDecimal
* @note this method may throw an exception if the literal value won't fit in a BigDecimal
*/
def litToBigDecimalOption: Option[BigDecimal] = {
litOption match {
Expand Down
2 changes: 1 addition & 1 deletion chiselFrontend/src/main/scala/chisel3/Num.scala
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ trait NumObject {
* @return
*/
def toBigDecimal(value: BigInt, binaryPoint: Int): BigDecimal = {
if(value.bitLength > 108) {
if(value.bitLength > MaxBitsBigIntToBigDecimal) {
throw new ChiselException(
s"BigInt $value with bitlength ${value.bitLength} is too big, precision lost with > $MaxBitsBigIntToBigDecimal bits"
)
Expand Down