1/*2Open Log Viewer*3* Copyright 20114*5* This file is part of the OpenLogViewer project.6*7* OpenLogViewer software is free software: you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation, either version 3 of the License, or10* (at your option) any later version.11*12* OpenLogViewer software is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with any OpenLogViewer software. If not, see http://www.gnu.org/licenses/19*20* I ask that if you make any changes to this file you fork the code on github.com!21*22*/23packageorg.diyefi.openlogviewer.utils; 24 25/**26* Math is used to provide math functions specific to the project.27* @author Ben Fenner28*/29publicfinalclassMathUtils { 30 31privateMathUtils() { 32 } 33 34publicstaticdoubleroundToSignificantFigures(finaldoubleinput,finalintsigFigs) { 35doubleabsoluteInput = 0; 36if(input == 0) { 37return0; 38 }elseif(input < 0) { 39 absoluteInput = -input; 40 }else{ 41 absoluteInput = input; 42 } 43 44finaldoubled = Math.ceil(Math.log10(absoluteInput)); 45finalintpower = sigFigs - (int) d; 46 47finaldoublemagnitude = Math.pow(10, power); 48finallongshifted = Math.round(input * magnitude); 49 50returnshifted / magnitude; 51 } 52 }