Number Of Decimal Places

Modified on 2013/05/11 13:26 by Eugene — Categorized as: Community Components

Syntax


public static int NumberOfDecimalPlaces(this double Num)

public static int NumberOfDecimalPlaces(double Num)

Parameter Description

NumA double value

Description

Simple static function to return the number of decimal places of an arbitrary entered number.

Example

Example below outputs the number of decimal places of an arbitrary number (here: the first fourteen digits of Pi).

Example using C# extension methods (with legacy syntax commented out):


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;

namespace WealthLab.Strategies { public class Numbers : WealthScript { protected override void Execute() { PrintDebug( 3.14159265358979.NumberOfDecimalPlaces() ); // This function is inside the Calculate class of Community.Components: //PrintDebug( Community.Components.Calculate.NumberOfDecimalPlaces( 3.14159265358979 ) ); } } }