Hey guys. It's been a while since I've been on these forums, but from experience I know you all are bunch of geeks So here's my question: is there a way to change the base of an exponent WITHOUT using logs, or for that matter, any non-integer number? I'm writing a program in MIPS and I need to convert a 10^x number to a 2^y number without using any of the float operations. Plus it's a fun mind game. Thanks!
You'll have problems if you can't use any non-integers. For example, when x=2, y=6.646. Or do you just mean you don't want to divide by 0.301 instead of log2?
10 = 2^(1/log2) (log is base 10) so 10^x = (2^(1/log2))^x = 2^(x/log2) therefore in your case y=x/log2 where log2 = 0.30102999.... Don't do programming so not sure if that's usable but it works from a maths point of view. Edit: sorry didn't see the non-integer bit, can't see any way of doing it otherwise atm
I'm not really familiar with the language you're using, but bear in mind that however you display it, the number is actually stored in binary, so given that you want a number as a base 2 exponential it makes sense to start from the binary (or maybe hex) value and convert this. While I think you can avoid logs by using binary, at some point you will have to deal with fractions (if only for displaying the final number), so I don't think you can avoid floats entirely. Is x an integer?
Thanks for your responses. Okay, so for clarity, here's the "entire" problem. ALL of the following variables are signed integers in binary. We're given three things to start; I'll call them by their register names. $a0 is the sign bit (that's the easy part, haha), $a1 is the mantissa, and $a2 is the exponent, so that the number is a non-normalized number in scientific notation like so: (-1)^($a0) * $a1 * 10^($a2) (These numbers are in base-10, for simplicity's sake) The final product should be a number that looks like this: (-1)^($v0) * 1.($v1) * 2^($v2) (These numbers are in base-2) where $v1 is essentially concatenated to the "1.", so it represents a fraction of sorts. (Note: I know there is no $v2 register, but I'm just using it as an example for clarity) To me, this problem boils down to a base conversion issue, but maybe I'm just approaching it at the wrong angle? Any ideas? Edit: GRRRR, professor just emailed the class and said that the input exponent is only in the range of [-8,8]. That just made the problem super-easy. Thanks for the help anyway, guys!