• 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. Equal numbers do not equal?

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 6616
  • 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

Equal numbers do not equal?

Martinsh
Martinsh over 2 years ago

In a layout design, pad size is got with following command:

objs = dbGetOverlaps(cvcp cvcp~>bBox padOpen 32 t)
    foreach(obj objs
        btObj = xpCommGetBottomObj(obj) ;; Get bottom shapes in hierarchy
        xOpen = rightEdge(btObj~>bBox)-leftEdge(btObj~>bBox)
        yOpen = topEdge(btObj~>bBox)-bottomEdge(btObj~>bBox)
        openSizeList = append(openSizeList list(xOpen yOpen))
)

It gives:

openSizeList
(64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0 64.0 64.0 64.0 64.0
64.0
)

All pad size is 64.0

But 

removeListDuplicates(openSizeList)
(64.0 64.0 64.0)  ;; Duplicates are not removed

openSizeMin = apply('min openSizeList)
64.0
openSizeMax = apply('max openSizeList)
64.0
openSizeMin==openSizeMax
nil  ;; 64.0 not equal to 64.0 ???


equal(openSizeMin openSizeMax)
nil  ;; 64.0 not equal to 64.0 ???


nearlyEqual(openSizeMin openSizeMax)
t  ;; nearly equal ??

I can't understand the return value by removeListDuplicates, equal, and == command. Please give me an explanation on this. Thanks!

BR,

Martin

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 2 years ago

    Martin,

    The subtraction is causing small floating point rounding errors - this is explained in numerous posts on the internet (not just about SKILL - it happens anywhere where IEEE floating point representation is used).  This is because the numbers are represented with a 53 bit binary mantissa, and so numbers that look simple in decimal (such as 0.1), these are recurring binary fractions (in the same way that 1/3 in decimal is 0.33333 recurring). That recurring binary digit then gets truncated at the 53rd bit, and manipulation of these numbers can lead to a loss of precision at the end of the sequence, leading to tiny differences when certain operations are performed.

    Put simply, you should never use == (equal) to compare floating point numbers (unless you know they are from the same source). So for example, you can compare x or y coordinates from the database because they will be converted the same way every time. However, if you manipulate these in some way then there's no guarantee they will not suffer from differences in loss of precision (the subtractions in your case).

    If you know the precision, you can do:

    precision=cv~>DBUperUU ; or you could give it a fixed number
    foreach(mapcar intSize removeListDuplicates(foreach(mapcar size openSizeList round(size*precision))) intSize/precision)

    Since the numbers are coming from the database, and that internally has integer precision, converting them back into integers and de-duping them first is a safe way to handle this.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Martinsh
    Martinsh over 2 years ago in reply to Andrew Beckett

    Andrew,

    Got it. Thanks for you explaination. 

    BR,

    Martin

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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