Bug? Power function errors.

Discussion in 'B4R Bugs & Wishlist' started by tigrot, Jan 30, 2018.

  1. tigrot

    tigrot Well-Known Member Licensed User

    Hi everybody,
    Seems power function's error strikes again. Many years ago I wrote an epilator firmware on a mega32 Atmel in assembly. I found some issue in power function. The results were non ok. Now I find that power(10,2) gives 99 as result. Maybe library is the same?
    Advice: avoid power functions!. You can live without...
     
  2. klaus

    klaus Expert Licensed User

    How did you test it?
    In B4A the result is 100!
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Tested on Arduino Mega:
    Code:
    Sub Process_Globals
       
    Public Serial1 As Serial
    End Sub

    Private Sub AppStart
       Serial1.Initialize(
    115200)
       
    Log("appstart")
       
    Log(Power(102))
    End Sub
    The result is 100.
     
    tigrot likes this.
  4. tigrot

    tigrot Well-Known Member Licensed User

    I was not able to reproduce the error. The power was inserted in a larger function. I used to convert a string to an integer value, but in case of number larger than 99 the result was always 1 less the expected result.
    I have already solved using an incremental multiply, but it was a surprize when I saw the log with value 99!
     
Loading...