• 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. Is there any procedure similar with atof(), but to consider...

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 13653
  • 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

Is there any procedure similar with atof(), but to consider scaling factor?

marcelpreda
marcelpreda over 7 years ago

Hi there,

Is there any procedure similar with atof() but to consider the scaling factors (u, m, k, M, G...)

I'm reading some data from text files, and where are floating numbers there could be also scaling/multiplicity factor.

Using atof() is ignoring the scaling factor, the only solution seems to be evalstring(). But I don't like it too much , because I don't know what other code could be executed.

So, is there something similar with atof(), but to consider those scaling factors?

What I mean:

numAsStr = "1.7m"

atof(numAsStr) => 1.7

evalstring(numAsStr) => 0.0017

BR,

Marcel

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

    Marcel,

    cdfParseFloatString() is a good choice for this.

    I'm happy that you don't like using evalstring for this - that's certainly bad practice, as you might unwittingly execute all sorts of code accidentally. I always give the example of a user accidentally entering "exit()" in a field that ends up being evaluated using evalstring...

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • marcelpreda
    marcelpreda over 7 years ago in reply to Andrew Beckett

    Thank you.

    Just tested, it works.

    Next question: cdfParseFloatString() is available by default, or a certain context has to be loaded ?

    Best Regards,

    Marcel

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • marcelpreda
    marcelpreda over 7 years ago in reply to Andrew Beckett

    Thank you.

    Just tested, it works.

    Next question: cdfParseFloatString() is available by default, or a certain context has to be loaded ?

    Best Regards,

    Marcel

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to marcelpreda

    Hi Marcel,

    It's a pcell-safe function (so that means you can use it in all executables, including dbAccess. Not in the "skill" executable though, but I doubt that matters!). Also it's a binary function, so doesn't require a context to be loaded.

    Regards,

    Andrew

    • 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