Post Go back to editing

Bug report in latest LTSpice Version (X64) 26.0.1

Thread Summary

The user encountered issues with parameter definitions in LTSpice, where .PARAM Gk=1/GBr^2 incorrectly resulted in Gk=GBr^2 and .PARAM Gk=1/(GBr^2) caused a division by zero error. The solution was to use the correct exponentiation operator ** instead of ^, e.g., .PARAM Gk=1/(GBr**2). The user confirmed that this resolved the problem.
AI Generated Content
Category: Software
Software Version: (X64) 26.0.1
.PARAM GBr=100  (Starting definition)
.PARAM Gk=1/GBr^2 actually results in Gk=GBr^2. Apparently, exponentiation overrides the previous division completely, even cancelling it out!
.PARAM Gk=(1/GBr)^2 works correctly, as does Gk=1/GBr/GBr, and this pair: .PARAM Ga=1/GBr  .PARAM Gk=Ga^2.
Also, a very likely related error:
.PARAM Gk=1/(GBr^2) actually results in a division by zero error message!
It appears that trying to perform squaring immediately after division breaks things, while doing division "separately" (including enclosed in parentheses) works. If this info is insufficient, I can supply the full circuit model.  I am modeling a PMDC motor with a gearbox.  The simulation works very well using my "correct" workarounds shown above.
RZetopan
  • ^ is a boolean operation. It you mean to square the number, use **. ^ is not for exponents :)

    try this:

    .PARAM Gk=1/(GBr**2)

  • Shades of FORTRAN!!  That never occurred to me!  That worked, but the parentheses were unnecessary. It does not matter if 1/GBr or GBr gets squared in this specific instance.  Thank you so much. By the way, I tried looking up the LTSpice mathematical operations list before filing my false bug report. It would be nice if there was a list available within the LTSpice "help" function. Of course, I never thought to check the boolean functions.

  • Hi  ,

    From the help:

    Numerical parameters support the following operations, grouped in reverse order of precedence of evaluation:

    Operand Description
    & Convert the expressions to either side to Boolean, then AND.
    | Convert the expressions to either side to Boolean, then OR.
    ^ Convert the expressions to either side to Boolean, then XOR.
       
    > True if expression on the left is greater than the expression on the right, otherwise false.
    < True if expression on the left is less than the expression on the right, otherwise false.
    >= True if expression on the left is greater than or equal the expression on the right, otherwise false.
    <= True if expression on the left is less than or equal the expression on the right, otherwise false.
       
    + Floating point addition
    - Floating point subtraction
       
    * Floating point multiplication
    / Floating point division
    % Remainder of floating point division, same as mod(x,y) function
       
    ** Raise left hand side to power of right hand side, only real part is returned, e.g., -2**1.5 returns zero, not 2.82843i

    mike