Find the answer to your Linux question:
Results 1 to 2 of 2
how can i convert? for example: 1e-06 -convert to-> 1.0u regardless what input number format. also convert to nearest scientific (1e-08 --> 100.0u)... example m, u, n, etc. i am ...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    1

    Smile number convert

    how can i convert?
    for example:

    1e-06 -convert to-> 1.0u

    regardless what input number format.

    also convert to nearest scientific (1e-08 --> 100.0u)... example m, u, n, etc.

    i am using csh.

    thanks

  2. #2
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    This is a perl module. If you are required to actually script the solution in csh, I think you are in for some interesting work. You could get some ideas from this module if you can read perl.
    Convert::SciEng supplies an object for converting numbers to and from scientific notation with user-defined formatting. Three different styles of fix are supported, standard CS, SI and SPICE:
    Code:
     SPICE  =    P    T    g    x    k   ''    m    u    n     p     f     a
     SI     =    P    T    G    M    K   ''    m    u    n     p     f     a
     Fix    = 1e15 1e12  1e9  1e6  1e3  1e0 1e-3 1e-6 1e-9 1e-12 1e-15 1e-18
    
     CS     =    P    T    G    M    K   ''
     Fix    = 2^50 2^40 2^30 2^20 2^10  2^0
    Methods are supplied for creating the object and defining which fix style it will use, and defining for format of numbers as they are converted to scientific notation.
    See Convert::SciEng - Convert 'numbers' with scientific postfixes - search.cpan.org fro more information.

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...