Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to format the length of a floating point number?

Status
Not open for further replies.

RajVerma

Programmer
Jun 11, 2003
62
DE
hi all,

suppose I have a number like '20.45672987988776880' and I want to truncate all the characters after the second position after the decimal, that means I want to get '20.45' out of it, then what is the syntax? I want the numbers only with atmost 2 characters after the decimal. I'm getting long numbers with the following statement.

set phase [format "%f" [expr $d * 0.00000008381903171539306640625]

but I don't need the long answer after calculation.

thanx in adv,
Raj.
 
Instead of "%f", try "%5.2f"

Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top