• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Weird numerical behavior

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 10106
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Weird numerical behavior

Weijie JIang
Weijie JIang over 3 years ago

Dear,

I got this weird numerical behavior in SKILL. Can anyone tell me why this is happening and how to avoid it?

Best,

Weijie

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    This will be because y1 is actually very slightly (due to floating point rounding errors) lower than 24 - and since the int function takes the integer part, it gets the number below.

    You can often see this by using:

    sstatus(fullPrecision t)
    y1

    but sometimes you might need one more digit than fullPrecision uses:

    printf("%.17g\n" y1)

    You can also see that if you do:

    y1-24.0 

    that you'll get a small residual negative value showing that y1 was slightly below 24 in practice.

    This floating point rounding behaviour is well documented in any programming language that uses IEEE floating point numbers (C, Python, etc) and there are articles on support.cadence.com that cover it too. Put simply it's down to the challenges of representing a decimal number using a binary mantissa. In the same way that 1/3 can't be exactly represented in decimal, 0.1 (1/10) can't be exactly represented in binary (it's a recurring fraction) - and so you lost digits at the end of the mantissa with certain floating point operations.

    Interestingly we've just been having discussions about a better way to make these rounding errors more evident.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Weijie JIang
    Weijie JIang over 3 years ago in reply to Andrew Beckett

    Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Weijie JIang
    Weijie JIang over 3 years ago in reply to Andrew Beckett

    Thanks!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information