• 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. How to change fixnum type into a string type

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 143
  • Views 15479
  • 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

How to change fixnum type into a string type

Carlsberg
Carlsberg over 12 years ago

Hi everyone!

How can I change a fixnum type (100.00) into a string type (“100.00”) ?

THX !!

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    First of all, 100.00 is not a fixnum, it's a flonum. A fixnum is an integer.

    The easiest is to use sprintf though. Either use:

    myreal=100.0
    myint=100

    sprintf(str "%d" myint) => "100"
    sprintf(str "%g" myreal) => "100"
    sprintf(str "%.2f" myreal) => "100.00"

    If you're only interested in the return value, you can pass nil as the first argument rather than the variable name.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Carlsberg
    Carlsberg over 12 years ago

     

    thank you very much!

    And I still have some confusions :

    when I try to combine a flonum(100.00) and a string (“k”),I use the  function:strcat .

    here are some procedure: 

    sum=sum+value   ;;both sum and value are flonun type

    mystring=strcat("sum" "k")   ;;;;the function does not work as I think.

    the result  I  expect to see is :mystring="100.00k" 

    would you plz help me ?

    thanks 

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

    It sounds as if it would be a very good idea for you to read the SKILL Language User Guide at <ICinstDir>/doc/sklanguser/sklanguser.pdf (can also be found in cdnshelp). I can't see why you would think that doing a strcat of two literal strings would do anything other than concatenate them together - so strcat("sum" "k") would clearly give "sumk" - since "sum" is in quotation marks, it's clearly a literal string, not a variable.

    If you want to get this as a string, you can do:

    sprintf(mystring "%.2fk" sum)

    Or you could have done:

    sprintf(sumAsString "%.2f" sum)
    mystring=strcat(sumAsString "k")

    And by the way, there's no tax on characters in this forum. English is my first language, so I rather like "please" being spelt correctly rather than an SMS-style abbreviation. It's one of those things I'm picky about, sorry...

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 12 years ago

     Hi,

    You could use the function aelSuffixWithUnits() to take the value and the units and produce a formatted result, for example:

    aelSuffixWithUnits("100.00" "k")
    => "100 k"
    
    OR print it with formatting (in this case "print" it to a string variable):
    
    sprintf(mystring "%g k" sum)
    => "100 k"
    

    The benefit of the aelSuffixWithUnits() function is that it can accept a floating point number or a string for its input.  You can control the decimal places etc. by modifying the format specifier '%g'

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Carlsberg
    Carlsberg over 12 years ago

    I am new to skill.And I am sorry about that.I will keep it in mind..

    thank you ! 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Carlsberg
    Carlsberg over 12 years ago
    thank you
    • 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