• 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. floating point issue

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 143
  • Views 13662
  • 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

floating point issue

Rojalin
Rojalin over 12 years ago

hi,

I have one list of floating numbers like below:

A= (0.0 0.36 1.44 1.8 2.16
    2.52 3.6 3.96 4.32 4.68
    5.76 6.12 6.48 6.84 7.92
    8.28 8.64 9.0 )

i have another floating number which comes from Xcoordinate of centerBox of a pin object which is 8.887.

I want to execute the following function:

 y=xCoord(centerBox(obj~>bBox))

for(k 0 length(A)

if(lessp(nth(k A) y) then printf("%.2f" nth(k A))

k=k+1)

this is giving an error message as follows

Error lessp:cant handle(nil <8.887)

can someone help me how to solve this?

thanks

 

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

    Before I get to the fact that that the approach you're using is wrong and rather inefficient, the reason it is failing is that your loop is going off the end of the list. There's two reasons for that - one is the fact that your loop goes to length(A) rather than length(A)-1 - and the other is the k=k+1 which also passes the end of the list. If the length of the list is L then nth(L A) will return nil - because it is zero-index.

    Using nth() to access a list is inefficient for anything other than very small lists, because lists are sequential. It's not clear to me precisely what you're trying to do with the k=k+1 bit, but doing this would be better:

    foreach(elem A
      if(lessp(elem y) then printf("%.2f " elem))
    )

    Regards,

    Andrew.

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

    Before I get to the fact that that the approach you're using is wrong and rather inefficient, the reason it is failing is that your loop is going off the end of the list. There's two reasons for that - one is the fact that your loop goes to length(A) rather than length(A)-1 - and the other is the k=k+1 which also passes the end of the list. If the length of the list is L then nth(L A) will return nil - because it is zero-index.

    Using nth() to access a list is inefficient for anything other than very small lists, because lists are sequential. It's not clear to me precisely what you're trying to do with the k=k+1 bit, but doing this would be better:

    foreach(elem A
      if(lessp(elem y) then printf("%.2f " elem))
    )

    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