简体   繁体   English

如何在Go中采用math / big.Float的指数?

[英]How to take the exponent of math/big.Float in Go?

I couldn't find anything in the API . 我在API中找不到任何内容。 Converting the number to a math/big.Int and back is not an option because the fractional component is significant to my calculation. 不能将数字转换为math/big.Int并返回,因为小数部分对我的计算很重要。


I'll end up repeatedly multiplying if there's no API, but that's a dissatisfying solution ( math/big.Int.Exp is just O(log(n)) ) which might not be practical when I run into this problem again. 如果没有API,我将反复重复乘法,但这是一个令人不满意的解决方案( math/big.Int.Exp只是O(log(n)) ),当我再次遇到此问题时可能不切实际。

Thanks! 谢谢!

You may use MantExp() to take the exponent of a big.Float for a particular base/mantissa. 您可以使用MantExp()采取的指数big.Float特定基础/尾数。 Note that the formula for calculating the exponent for a given mantissa is: 请注意,计算给定尾数的指数的公式为:

x == mant × 2**exp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM