Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
Learn How to Create Your Own Programming Language
createyourproglang.com
Recent
FILE HOSTS PREMIUM ACCOUNT
ALL FILE HOST PREMIUM ACCOUNTS
Zynga Slingo Trainer v5.12
iTunes Gift Card Generator V3.1 2012
Diablo 3 GOLD Coins FREE
Working PS3 Jailbreak 3.65 And 3.66
ExtaBit Premium Accounts and Cookies
Steam Wallet Hack - Money Adder & Hack v3
Empires & Allies Hack Cheat Trainer v5.4.1
Eve Onnline 60 Days Time Card Generator v2
Popular
XBOX POINTS GENERATOR - MICROSOFT POINTS GENERATOR v1.2012
11 may 2012 premium uploading accounts 100% working
Free Microsoft Points
Free Microsoft Points - Microsoft Points Generator - Xbox Live Codes 2012
Car Town Free Blue Points Hack
Free CarTown Blue Points Generator and CarTown Templates
Better way to get content via jQuery $.get()
Free Microsoft Points
Simple Days Purger
Sharecash Downloader Bypass Surveys New 05/2012
Pastable version of
Tracking error in numbers
<pre class='prettyprint' language='ruby'>class ENumber attr_accessor :n, :e def initialize( number, error ) @n = number @e = error end # Basic arithmetic. Call like (ENumber1 + ENumber2) def +(o); ENumber.new(@n+o.n, @e+o.e); end def -(o); ENumber.new(@n-o.n, @e+o.e); end def *(o); ENumber.new(@n*o.n, multError(o)); end def /(o); ENumber.new(@n/o.n, multError(o)); end # Trigonometric functions. Call like "myENumber.cos" def tan; trig(:tan); end def sin; trig(:sin); end def cos; trig(:cos); end # Print this ENumber with the number and error rounded to x and y, respectively. # Probably should find the real way to print a +/-. since it screws up when I edit # this file on a terminal without UTF-8 (ie. almost any terminal) def to_s(x=4,y=x) "%.#{x}f±%.#{y}f" % [@n, @e] end private def trig(type) fcn = Math.method(type) ENumber.new(fcn.call(@n), 0.5*(fcn.call(@n+@e)-fcn.call(@n-@e)).abs ) end def multError(o) (@n * o.n).abs * ((@e / (@n.abs)) + (o.e / (o.n.abs))) end end # Normally this file will be included as a library. # If it's loaded directly, run the below. Demo/example/cheap-ass-unittest. if __FILE__ == $0 n = ENumber.new(3,0.5) m = ENumber.new(4,0.25) puts (((m*n).tan)+n).to_s(5,6) end</pre> <a href="http://www.refactormycode.com/codes/342-tracking-error-in-numbers" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://www.refactormycode.com/images/small_logo.gif" style="border:0" /></a>