cadence calculator?

Discussion in 'Cadence' started by Erik Wanta, Jul 11, 2003.

  1. Erik Wanta

    Erik Wanta Guest

    If I enter 5/3 in the Cadence calulator, I get 1 instead of 1.666667.
    How do I specify how many digits to display?

    aelPushSignifDigits(10) doesn't work
     
    Erik Wanta, Jul 11, 2003
    #1
  2. When specifying integers as operands, Cadence just performs integer
    calculation. You have to enter 5.0/3 to get the desired result.

    mk
     
    Matthias Klein, Jul 11, 2003
    #2
  3. Erik,

    5/3 is an integer division, and so the correct answer is 1. It's not to do with
    precision. You need to do either:

    5.0/3
    5/3.0
    5.0/3.0

    (having one of the numbers as a float will force the calculation to
    be done as a float). Whilst this might seem unusual in a calculator, it is
    not unusual in a programming language (the same behaviour would be seen
    in C). Since the calculator is in essence a SKILL expression builder, and
    SKILL has the same kind of rules as C for algebraic expression handling,
    that's why this happens.

    aelPushSignifDigits only has an affect on ael expressions (such as instance
    parameter expressions), not SKILL. SKILL evaluates to the full double
    precision floating point - provided that the expression is a floating
    point expression rather than an integer expression. However, it would
    normally just show up (in the default print representation) using around
    6 or 7 digits - to get SKILL to display return values with greater precision
    you can use:

    sstatus(fullPrecision t)

    Regards,

    Andrew.
     
    Andrew Beckett, Jul 11, 2003
    #3
  4. Erik Wanta

    Erik Wanta Guest

    I understand what you guys are saying, but I don't like it. I would
    expect that the Cadence calculator would act the same as my pocket
    calculator. If I want to do integer division, then I could just use
    the floor() function.

    Thank you for contacting Cadence Customer Support.
    The Service Request identification number is 32507128
     
    Erik Wanta, Jul 11, 2003
    #4
  5. Erik,

    You might not like it, but it has been this way for many, many years, and to
    change it would bring about an incompatibility which would break things for
    people who are depending on this behaviour.

    Other languages also have the concept of integer arithmethic too - (C for
    example) - if there is nothing to cast the type, then it should use the type of
    the numbers. We certainly can't change it in SKILL without breaking things.

    Andrew.
     
    Andrew Beckett, Jul 28, 2003
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.