Imports System.Runtime.CompilerServices

Namespace Extensiones
    Public Module DoubleExtensions
        <Extension()> Function APalabras(Numero As Double) As String
            Return NumerosAPalabras.ToCardinal(Numero)
        End Function

        <Extension()> Function AEurosEnLetras(Numero As Double) As String
            Dim EnteroDecimal As Int32 = Int(Math.Round((Numero - Int(Numero)) * Math.Pow(10, 2)))
            If EnteroDecimal > 0 Then
                Dim convertidor As New NumerosAPalabras(True, "", "Euros con", True)
                Return convertidor.ToCustomCardinal(Numero).Trim & " céntimos"
            Else
                Return NumerosAPalabras.ToCardinal(Numero).Trim & " Euros"
            End If
        End Function
        <Extension()> Function EntreValores(Valor As Double, RangoMenor As Double, RangoMayor As Double) As Boolean
            Return Valor >= RangoMenor And Valor <= RangoMayor
        End Function
        <Extension()> Function NothingA0(Valor As Double?) As Double
            Return If(Valor.HasValue, Valor, 0)
        End Function

    End Module
End Namespace
