Skip to content
Bugfix for the rounding error in SFAR's Thoracoscore calculator
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
calculator.html
fixed.html
thoracoscore2.php

README.md

Bugfixes for SFAR's Thoracoscore calculator

tl;dr

The Société Française d’Anesthésie et de Réanimation provides Google's top-ranked result for a Thoracoscore calculator. Their Thorascore calculator has a systematic error that introduces an addition of 0.05% to all scores that it calculates. We provide a patched version of their calculator's Javascript that corrects this error. We presented our findings at the Society for Cardiothoracic Surgery for Great Britain & Ireland's 2012 Annual Meeting.

The Error

SFAR's Thoracoscore calculator uses the following function to attempt to round the calculated score (x) to 2 decimal places:

	function Fmt(x) {
		var v
		if (x >= 0) {
			v = '' + (x + 0.05)
		} else {
			v = '' + (x - 0.05)
		}
		return v.substring(0,v.indexOf('.')+3)
	}

As x is always ≥0, this adds 0.05 to x before the substring method truncates the string to 2 decimal places. This does not round to 2 decimal places. What was perhaps meant was to add 0.005 before truncating to 2 decimal places; this would be a valid rounding function.

We suggest the alternative:

	function Fmt(x) {
		return Math.round(x * 100) / 100;
	}

Files

We provide 3 files:

Presentation

We presented our findings at the Society for Cardiothoracic Surgery for Great Britain & Ireland's 2012 Annual Meeting. Our slides are on SpeakerDeck:

Title slide

Authors

  • Kenrick Turner (@kenners), Norfolk & Norwich University Hospital
  • Andrew Ho (@andrewlkho), St. George's Hospital, London
  • Gunnar Rø (@gulfa), University of Durham
  • Martin Turner
  • Filip Van Tornout, Norfolk & Norwich University Hospital

Contact

Correspondance should be addressed to Kenrick: kenrickturner[at]nhs.net

You can’t perform that action at this time.