Skip to content

Dead code in GetNumber see description #2

@PascalCorpsman

Description

@PascalCorpsman
// Next check for scientific notation
  If (Fch = 'e') Or (Fch = 'E') Then Begin
    // Then it's a float. Start collecting exponent part
    If FTokenRecord.FToken = tInteger Then Begin  // <---- This always treats Numbers with exponents as FLoats
      FTokenRecord.FToken := tFLOAT;
      FTokenRecord.FTokenFloat := FTokenRecord.FTokenInteger;
    End;
    Fch := nextchar;
    If (Fch = '-') Or (Fch = '+') Then Begin
      If Fch = '-' Then exponentSign := -1;
      Fch := nextchar;
    End;
    { accumulate exponent, check that first ch is a digit }
    If Not isDigit(Fch) Then
      Raise EScannerError.Create('syntax error: number expected in exponent');


    evalue := 0;
    Repeat
      singleDigit := ord(Fch) - ord('0');
      If evalue <= (MAX_EXPONENT - singleDigit) Div 10 Then Begin
        evalue := 10 * evalue + singleDigit;
        Fch := nextchar;
      End
      Else
        Raise EScannerError.Create('exponent overflow, maximum value for exponent is ' + inttostr(MAX_EXPONENT));
    Until Not isDigit(FCh);

    evalue := evalue * exponentSign;
//    If token = tInteger Then     <--- This if will always evaluate to false see comment above
//      FTokenRecord.FTokenFloat := FTokenRecord.FTokenInteger * IntPower(10, evalue)
//    Else
      FTokenRecord.FTokenFloat := FTokenRecord.FTokenFloat * Power(10.0, evalue);
  End;  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions