Home > Community > Forums > Custom IC Design > Changing floating number precision in SKILL

## Email

Recipients email * (separate multiple addresses with commas)

Message *

 Send yourself a copy

## Subscribe

Intro copy of the newsletter section here, some intro copy of the newsletter. Instruction of how to subscribe to this newsletter.

First Name *

Last Name *

Email *

Company / Institution *

 Send Yourself A Copy

# Changing floating number precision in SKILL

Last post Tue, Oct 27 2009 8:04 AM by sprinter. 4 replies.
 Started by sprinter 26 Oct 2009 02:17 PM. Topic has 4 replies and 1765 views
• #### Mon, Oct 26 2009 2:17 PM

• sprinter
• Joined on Tue, Sep 29 2009
• Posts 17
• Points 310
Changing floating number precision in SKILL
 How can I change the precision of a floating number. For example I'm trying to convert 23.3455 to 23.34 & this's what I'm doing: x=23.3255y=printf("%5.2f" x)'y' is now a symbol. HOw can this be converted to a floating number? Thanks,Adil
• Post Points: 35
• #### Mon, Oct 26 2009 5:33 PM

• kbhow
• Joined on Thu, May 7 2009
• Penang, Pulau Pinang
• Posts 120
• Points 2,045
Re: Changing floating number precision in SKILL
 Hi Adil,In order to get the value of a string, you can use function evalstring.Eg: x = 23.3255      sprintf(y "%5.2f" x)  ; this will return y="23.33"      evalstring(y) ; evaluate string value, you will get your answer here Happy testingHow
• Post Points: 5
• #### Mon, Oct 26 2009 5:55 PM

• Quek
• Joined on Wed, Oct 14 2009
• Singapore, 00-SG
• Posts 1,078
• Points 16,395
Re: Changing floating number precision in SKILL
• Post Points: 20
• #### Mon, Oct 26 2009 9:26 PM

Re: Changing floating number precision in SKILL
 Personally I never like using evalstring for things like this.I'd probably do:y=round(x*100)/100.0If you really want to use the sprintf approach, you could use atof() instead of evalstring.Regards,Andrew
• Post Points: 20
• #### Tue, Oct 27 2009 8:04 AM

• sprinter
• Joined on Tue, Sep 29 2009
• Posts 17
• Points 310
Re: Changing floating number precision in SKILL