;==================== begin sigfigs.nls ======================================== ; sigfigs - Like precision but specifies number of significant figures. ; ; By Rik Blok, 2013 ; ; This is free and unencumbered software released into the public domain. ; ; Anyone is free to copy, modify, publish, use, compile, sell, or ; distribute this software, either in source code form or as a compiled ; binary, for any purpose, commercial or non-commercial, and by any ; means. ; ; Provides: ; ; sigfigs ; Like precision but specifies number of significant figures. ; sigfigs-other ; Like sigfigs but to same precision as another number. ; ; Example: ; ; ; print pi to 3 sigfigs (3.14) ; print sigfigs pi 3 ; ; ; print ticks to same digit as dt ; print sigfigs dt 2 ; tick-advance dt ; print sigfigs-other ticks dt 2 ; ; Revisions: ; ; 2013-08-03 - initial release by Rik Blok ;------------------------------------------------------------------------------- to-report sigfigs ; Reports first _digits_ of _number_. ; Parameters: [ number ; Number to report. digits ; Report this many significant figures. ] report precision number (digits - ceiling log number 10) end to-report sigfigs-other ; Reports _number_ to same decimal as _digits_ sigfigs of _other-number_. [ number ; Number to report. other-number ; Other number to match sigfigs. digits ; Significant figures of other number to match. ] report precision number (digits - ceiling log other-number 10) end ;==================== end sigfigs.nls ==========================================