Bugs in Trigon library Log and Log10 functions

General discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

Bugs in Trigon library Log and Log10 functions

#1 Post by OT » 07 Mar 2010 06:47

Very large numbers are resulting for log and log10 inputs between 0.0 and 1.0 instead of the correct results, for instance log(0.5) should be -0.69314718 (= ln(0.5)). Do not know if this has been reported before.

Code: Select all

program EXPLogtest;

{ Declarations section }
var
  Var1,Var2 : Real;
  txt       : Array[23] of Char;
// LCD module connections
var LCD_RS : sbit at LATD0_bit;
var LCD_EN : sbit at LATD2_bit;
var LCD_D4 : sbit at LATB4_bit;
var LCD_D5 : sbit at LATB5_bit;
var LCD_D6 : sbit at LATB6_bit;
var LCD_D7 : sbit at LATB7_bit;
var LCD_RS_Direction : sbit at TRISD0_bit;
var LCD_EN_Direction : sbit at TRISD2_bit;
var LCD_D4_Direction : sbit at TRISB7_bit;
var LCD_D5_Direction : sbit at TRISB6_bit;
var LCD_D6_Direction : sbit at TRISB5_bit;
var LCD_D7_Direction : sbit at TRISB4_bit;
// End LCD module connections

begin
  Delay_ms(2000);
  LATB      := $0000;
  TRISB     := $0000;
  ADPCFG    := $FFFF; // PORTB is digital
  LATD      := $0000;
  TRISD     := $0000;           // configure pins of portd as output
  LCD_Init();
  LCD_Cmd(_LCD_CURSOR_OFF);
  While true do begin
    Var1:=0.5;
    FloatToStr(var1,txt);
    LCD_out(1,1,txt);
    Var2:=log(var1);     //ln(0.5) should be -0.69314718
    FloatToStr(var2,txt);
    LCD_out(2,1,txt);
    Var2:=log10(var1);   //log(0.5) should be -0.3010210
    FloatToStr(var2,txt);
    LCD_out(2,10,txt);
    Delay_ms(2000);
  end;

end.

User avatar
anikolic
mikroElektronika team
Posts: 1775
Joined: 17 Aug 2009 16:51
Location: Belgrade
Contact:

Re: Bugs in Trigon library Log and Log10 functions

#2 Post by anikolic » 08 Mar 2010 12:05

Hi OT,
Thank you very much for reporting this, I have recreated this error and I filed a bug report to our developers. We will investigate the issue and correct it for the following Beta release.

Sorry for the inconvenience and thank you for your support. I will inform you here when the bug is resolved.

Best regards,
Aleksandar
Web Department Manager

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 General”