• 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 6078
  • 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
  • skillUser
    skillUser over 15 years ago

    Hi,

    Neither a bug or a feature!  You show x1 as being 130810.0, but it may actually be internally represented as 130809.999997 (say), so it may display as 130810.0, but when you truncate the fractional part to make it an integer, you see 130809.  You can print more digits of a floating point number, e.g. using printf() to check this for yourself, something like the following:

     printf("%6.8f" x1) 
     => 130809.99999700

    The default print representation of a floating point may give you up to 6 digits of precision, but only for about 7 significant digits, so if the number is already 6 digits 'wide', then you will only get one digit of precision and the number is rounded when it is presented to you.

    I hope that this helps to answer your question, or at least helps you to understand what is happening.

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • skillUser
    skillUser over 15 years ago

    Hi,

    Neither a bug or a feature!  You show x1 as being 130810.0, but it may actually be internally represented as 130809.999997 (say), so it may display as 130810.0, but when you truncate the fractional part to make it an integer, you see 130809.  You can print more digits of a floating point number, e.g. using printf() to check this for yourself, something like the following:

     printf("%6.8f" x1) 
     => 130809.99999700

    The default print representation of a floating point may give you up to 6 digits of precision, but only for about 7 significant digits, so if the number is already 6 digits 'wide', then you will only get one digit of precision and the number is rounded when it is presented to you.

    I hope that this helps to answer your question, or at least helps you to understand what is happening.

    Regards,

    Lawrence.

    • 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