Ok, I made this thing during a project class at uni during a break... so don't expect me having tested it, I just wrote it from my thoughts right away

[syntax="QBASIC"]DECLARE FUNCTION GetExponent%(Value AS INTEGER, BaseValue AS INTEGER)

'/********************************************************************

' Calculates and returns the integer exponent of BaseValue^x=Value,

' if it exists, in which x is a positive integer number in I.

' Value and BaseValue are required to be postive integer numbers

' Returns -1 if the exponent doesn't exist

' The parameters and return value all span I-positive < 32767

' ********************************************************************/

FUNCTION GetExponent(Value AS INTEGER, BaseValue AS INTEGER)

' /*****************************************************

' Exclude some general mathematical exceptions to LOG

' *****************************************************/

IF BaseValue = 1 AND Value <> 1 THEN

GetExponent = -1: EXIT FUNCTION

ELSEIF (BaseValue = 1 AND Value = 1) OR (BaseValue = 0 AND Value = 0) THEN

GetExponent = 1: EXIT FUNCTION

END IF

IF BaseValue < 1 OR Value < 0 THEN

GetExponent = -1: EXIT FUNCTION

END IF

'/**********************************

' Calculate the exponent required

' **********************************/

Exponent# = LOG(CDBL(Value)) / LOG(CDBL(BaseValue))

'/**********************************************************

' See if it is an integer exponent and return it if it is

' **********************************************************/

IF Exponent# = INT(Exponent#) THEN

GetExponent = INT(Exponent#)

ELSE

GetExponent = -1

END IF

END FUNCTION

[/syntax]Forgive me this bad-looking code, I haven't coded in a while so it may look a bit messy.

You can call it like

[syntax="QBasic"]PRINT GetExponent(128, 2) 'should return 7 because 2^7=128[/syntax]

A small UI program incorporating this can be as follows (warning: simple and bad code

(don't have much time to do complex fun))

[syntax="QBASIC"]INPUT "Enter the value:", v%

INPUT "Enter the base:", b%

e% = GetExponent(v%, b%)

IF e% = -1 THEN

PRINT "The integer exponent of value "; v%; " and base "; b%; " does not exist"

ELSE

PRINT "The integer exponent of value "; v%; " and base "; b%; " equals "; e%

END IF[/syntax]

Hope it works