LCD displays inf

Hi,

I’m trying to display the value of the logarithm onto a 16x2 lcd screen and the output continues to be inf if I use a whole fraction as my input number to the logarithm. If I input just a finite decimal number with a fixed number of decimal points(example 0.34563), then the log output is fine and I get a number. I am assuming that the output from the fraction will extend to infinite decimal points resulting in a very long decimal number from the logarithm which the arduino is unable to handle.

Is there a way to truncate the number I have stored as “Number” in my sketch to a finite decimal point value? So that the output from “Number” is a finite number to the input of the logarithm function. Or is there a different method recommended? Thank you.

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void keypad() {
int x;
  x = analogRead (0);
  lcd.setCursor(0,1);
  
  if (x < 60) {
float Number;
float logValue;
    Number = 24534/50392;
    logValue = (-1)*((log(Number))/(log(10)));    //-log10(X)
    
    lcd.clear();
    lcd.setCursor(0,0);      //Top Row
    lcd.print("Number      ");
    lcd.setCursor(0,1);      //Bottom Row
    lcd.print(logValue,6);       
  }
}

void setup() {
}
void loop() {
keypad();
}
    Number = 24534/50392;

24534 / 50392 == 0 24534.0 / 50392.0 == 0.4868...

Hope that helps.

THANK YOU. That's perfect.

Delta_G:     Number = 24534/50392;

24534 / 50392 == 0 24534.0 / 50392.0 == 0.4868...

Hope that helps.