How to compute an exponent in matlab without getting inf?

前端 未结 3 898

The title says it all: I want to calculate an exponent in matlab with big numbers, but I get overflow and it just returns infinity.

>> 100^1000

ans =
         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-06 02:45

    Working with 64bit floating point arithmetic, 100^1000 is inf because it is larger than the largest possible value. If the symbolic math toolbox is available, use vpa or sym to work with large numbers:

    sym('100^1000')
    

    or

    vpa('100^1000')
    

提交回复
热议问题