0
|
8947 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
GROUPS:

# Converting BaseForm Result into a Usable Integer for Computation

Posted 9 years ago
 I am trying to do the following: theMin = BaseForm[16^^1000,10] theMax = BaseForm[16^^10000,10] N[20*Log10[theMax/theMin]]  However this results in an error because Head[theMin] is BaseForm. How can I convert "theMin" and "theMax" from the "display BaseForm" formats into an integer format that can be used for computation? What I want to get is the following N[20*Log10[65536/4096]] 24.0824 
5 Replies
Sort By:
Posted 9 years ago
 Bruce, thanks that is great - I did not know you could do the assignment inside the Form function. It would be nice if Mathematica added a parameter/property to the built-in Head function that allowed the user to specify the desired format for a variable and then the return value of the Head function could be a list of recommended options (or function paths) to get to that result. I know that sounds like a complicated (and crazy) request but it would be a slick option.@John, thanks for providing the alternative unwrap method as well.
Posted 9 years ago
 What are you really trying to do, anyway? Why use BaseForm to display base 10, when base 10 is the default?
Posted 9 years ago
 Unwrap before numericizing: In:= 20*Log10[theMax/theMin] /. BaseForm[x_, _] -> x // N Out= 24.0824 
Posted 9 years ago
 This question comes up with TableForm and MatrixForm a lot. The solution is to do the assignment inside the *Form function. In:= BaseForm[theMin = 16^^1000, 10] Out//BaseForm= 4096 In:= theMin Out= 4096 In:= Head[theMin] Out= Integer Usually, the content of the *Form wrapper can be extracted with First. In:= aMin = BaseForm[16^^1000, 10] Out//BaseForm= 4096 In:= First[aMin] Out= 4096 
Posted 9 years ago
 Actually this worked........ theMin2 = FromDigits["1000",16] theMax2 = FromDigits["10000",16] N[20*Log10[theMax2/theMin2]] 24.0824 It would be nice if it were possible to wrap a built-in function around BaseForm to be able to reuse the BaseForm variables in other calculations