Which value a and e must have to meet the conditions?

59 Views Asked by At

I'm trying to implement an algorithm to solve conversion of base, and I'm stuck.

I want to express value in this form: $ v = a×b^e$ . How can I solve this problem? If a $\epsilon \ I_{\ne 0}\ , e \ \epsilon \ I$ and v and b are given.

An example:

$v = 0.02 ;\ b = 10;$

Which smallest value of a and e must have to meet the conditions?

Foreword, I apologize if there's misunderstood, it's my first time posting here in MathStackExchange.

1

There are 1 best solutions below

1
On BEST ANSWER

I Assume that $I$ is supposed to the integers. (Commonly we denote the integers by $\Bbb Z$ - when I is used to represent a set of numbers, most commonly that set will be $[0,1]$, all numbers $\ge 0$ and $\le 1$. But there is no standard meaning for $I$. If you do not already know - for certain - that some notation you are using is a widely practiced standard, it is best to define/explain the notation instead of just assuming everyone will understand.)

There are two cases you have to consider:

  • $v$ has a terminating expansion in base $b$. Equivalently, there is some integer $n$ such that $b^n v$ is an integer. Then the $e$ you want will be the lowest such $n$. A simple-minded algorithm to find $e$ and $a$ would be:
    • If $v$ is integer, keep dividing by $b$ until the result is no longer integer. $e$ will be the number of times you divided and got an integer result. $a$ is the last integer result you got.
    • If $v$ is not integer, keep multiplying by $b$ until you get an integer result. $e$ will be the opposite of the number of times you multiplied by $b$ to get that integer result. $a$ will be the integer result.
  • $v$ does not have a terminating expression in base $b$. Equivalently, for every integer $n, b^nv$ is not integer. In this case the problem cannot be solved. Such numbers (which include almost all numbers) cannot be expressed as $a\times b^e$ for any integers $a$ and $b$.

Even when you restrict to numbers representable on a computer, unless $b$ is even, the vast majority of representable numbers will not have a terminating base $b$ expansion. I.e., they cannot be expressed as $a\times b^e$ for integer $a, e$.