Template:Sigfig: Difference between revisions

No edit summary
No edit summary
Line 1: Line 1:
{{#expr:({{{1}}}) round ({{{2|3}}} - floor (ln (abs ({{{1}}}))/ln (10)) - 1)}}
<includeonly>{{#expr:({{{1}}}) round ({{{2|3}}} - floor (ln (abs ({{{1}}}))/ln (10)) - 1)}}</includeonly><noinclude>
This template rounds a number to a given number of significant figures. The first argument is the number to be rounded. The second argument is the number of significant figures. If not specified the default value is 3.
 
== Usage ==
; You type
: <code><nowiki>{{sigfig|1234.567|5}}</nowiki></code>
 
; You get
: 1234.6
 
[[Category:Templates]]
</noinclude>