• 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. Bug or feature?

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 142
  • Views 6080
  • 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

Bug or feature?

Slawa
Slawa over 15 years ago

 Hello

 In my script the following is used
x1=y/0.01
x1t=truncate(x1)
If x1 - an integer that x1t should be equal in a case x1 but

if y=1308.1 then
x1=130810.0
x1t=130809

Why??

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

    It's not a bug. This is a normal consequence of floating point calculations in any language (C, Tcl, perl - you name it). Many things on the web about this, but this is a good reference:

    http://docs.sun.com/source/806-3568/ncg_goldberg.html

    Try doing x1-130810 and you'll see that x1 is a tiny amount below 130810 and hence when truncated it ends up as 130809. It's caused by the fact that 0.01 is an infinitely recurring sequence in binary, rather like 1/3 is 0.333 recurring in base 10 - and so if you truncate the number to a finite precision, you end up with rounding errors.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 15 years ago

    It's not a bug. This is a normal consequence of floating point calculations in any language (C, Tcl, perl - you name it). Many things on the web about this, but this is a good reference:

    http://docs.sun.com/source/806-3568/ncg_goldberg.html

    Try doing x1-130810 and you'll see that x1 is a tiny amount below 130810 and hence when truncated it ends up as 130809. It's caused by the fact that 0.01 is an infinitely recurring sequence in binary, rather like 1/3 is 0.333 recurring in base 10 - and so if you truncate the number to a finite precision, you end up with rounding errors.

    Regards,

    Andrew.

    • 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