crashanalysercmd/PerfToolsSharedLibraries/Engine/SymbianUtils/Utilities/NumberFormattingUtils.cs
changeset 0 818e61de6cd1
equal deleted inserted replaced
-1:000000000000 0:818e61de6cd1
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 using System;
       
    18 
       
    19 namespace SymbianUtils
       
    20 {
       
    21 	public class NumberFormattingUtils
       
    22 	{
       
    23 		public static string NumberAsPercentageInt( long aValue, long aOneHundredPercentValue )
       
    24 		{
       
    25 			float percent = (float) aValue / (float) aOneHundredPercentValue;
       
    26 			percent *= (float) 100.0;
       
    27 			//
       
    28 			int percentAsInt = Math.Min( 100, ( (int) ( percent + 0.5 ) ) );
       
    29 			string ret = percentAsInt.ToString();
       
    30 			return ret;
       
    31 		}
       
    32 
       
    33 		public static string NumberAsPercentageOneDP( long aValue, long aOneHundredPercentValue )
       
    34 		{
       
    35 			double percent = (double) aValue / (double) aOneHundredPercentValue;
       
    36 			percent *= (double) 100.0;
       
    37 			//
       
    38 			string ret = percent.ToString("##0.0");
       
    39 			return ret;
       
    40 		}
       
    41 
       
    42 		public static string NumberAsPercentageTwoDP( long aValue, long aOneHundredPercentValue )
       
    43 		{
       
    44 			double percent = (double) aValue / (double) aOneHundredPercentValue;
       
    45 			percent *= (double) 100.0;
       
    46 			//
       
    47 			string ret = percent.ToString("##0.00");
       
    48 			return ret;
       
    49 		}
       
    50 
       
    51 		public static string NumberAsPercentageThreeDP( long aValue, long aOneHundredPercentValue )
       
    52 		{
       
    53 			double percent = (double) aValue / (double) aOneHundredPercentValue;
       
    54 			percent *= (double) 100.0;
       
    55 			//
       
    56 			string ret = percent.ToString("##0.000");
       
    57 			return ret;
       
    58 		}
       
    59 	}
       
    60 
       
    61 }