Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Number::Spice 0.011

    Download button

    No screenshots available
    Downloads: 365  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Wim Verhaegen | More programs
    Perl Artistic License / FREE
    November 22nd, 2007, 19:50 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Number::Spice description

    It allows handling of Spice number strings.

    Number::Spice allows handling of Spice number strings.

    SYNOPSIS

    use Number::Spice qw(:convert);

    print spice_to_number('5u'); # 5E-6
    print spice_to_number('1.0e4k'); # 1.0E7

    print number_to_spice(1.0e12); # 1T
    print number_to_spice(1.0e-2); # 10M (i.e. milli, not mega!)

    Number::Spice was written to support the number format used in the syntax for netlists for the spice electrical circuit simulator. This number format is also used in other applications, even in different fields. Number::Spice can be used to any purpose, and does not require the installation of the spice simulator.

    Spice syntax provides a shortcut for writing down numbers in scientific notation, by appending a suffix to the value which corresponds to a numeric multiplier. The following table lists the minimal suffices and the corresponding multiplier:

    T 1.0E12
    G 1.0E9
    MEG 1.0E6
    X 1.0E6
    K 1.0E3
    M 1.0E-3
    MIL 2.54E-5 (i.e. 1/1000 inch)
    U 1.0E-6
    N 1.0E-9
    P 1.0E-12
    F 1.0E-15
    A 1.0E-18

    USAGE

    FUNCTIONS

    The following functions are provided. All functions are available for exporting.

    pattern

    Returns the regular expression matching a Spice number.

    is_spice_number($spice_number)

    Returns true is the given string matches a Spice number after removal of leading and trailing whitespace. Note that a plain number, i.e. without literal suffix, is also accepted as a valid Spice number.

    split_spice_number($spice_number)

    Examines a string and returns a list holding a number and a spice suffix if the string holds a valid spice number. Returns undef otherwise.

    Note that a regular number is also considered to be a spice number, and an empty string will be returned as the suffix in this case.

    suffix_value($suffixc)

    Returns the value of a given spice suffix, e.g. suffix_value('giga') yields 1.0E9.

    spice_to_number($spice_number)

    Returns a regular number represented by the given spice number. spice_to_number() will die() if the given number is not a spice number.

    number_to_spice($number)

    Returns the shortest spice number representing the given number. Note that no conversion to mil will be attempted, and numbers smaller than 1.0E-18 will not get a suffix.

    normalize_spice_number($spice_number)

    Converts a spice number to its shortest form by invoking spice_to_number() and number_to_spice().

    REGULAR EXPRESSIONS

    In addition to the methods, the following scalars representing regular expressions are also made available for exporting:

    $RE_NUMBER

    matches a regular number

    $RE_SPICE_SUFFIX

    matches any spice suffix

    $RE_SPICE_NUMBER

    matches a spice number. Note that a regular number is considered a spice number with no suffix. If you need to check for pure spice numbers, i.e. numbers with a literal suffix, check with /$RE_NUMBER$RE_SPICE_SUFFIXb/ instead.

    EXPORT TAGS

    The functions and regular expressions are tagged into the following groups for easy importing:

    convert

    spice_to_number(), number_to_spice() and normalize_spice_number()

    re

    $RE_NUMBER, $RE_SPICE_SUFFIX and $RE_SPICE_NUMBER

    all

    All conversion functions and regular expressions

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    number strings | Spice numbers | Perl module | Spice | number | strings

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM