Find the answer to your Linux question:
Results 1 to 3 of 3
Hey guys, I'm new to linux and I'm trying to bring some korn shell code over from an HP-OS operating system. In HP, decimal numbers do not have to be ...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    1

    ksh on linux - declaring decimals

    Hey guys, I'm new to linux and I'm trying to bring some korn shell code over from an HP-OS operating system. In HP, decimal numbers do not have to be declared, but in linux I"m getting errors for the decimal points. Can someone tell me how to declare my variables? Something like:
    integer abc=0
    only for decimal numbers.


  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.

    Welcome to the forum.
    Code:
    #!/bin/ksh
    
    # @(#) s1       Demonstrate floating-point.
    
    # man ksh: float='typeset -lE'
    
    echo
    echo "(Version information from local command \"version\")"
    version >/dev/null 2>&1 && version =o $(_eat $0 $1)
    
    float a=1.1
    typeset -lE b=3.3
    
    echo
    printf " Difference between $b and $a is %f\n", $(( b-a ))
    
    exit $?
    Producing:
    Code:
    $ ./s1
    
    (Version information from local command "version")
    Linux 2.6.22-3-686
    ksh 93s+
    
     Difference between 3.3 and 1.1 is 2.200000
    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 )

  3. #3
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    Are you using the real korn shell, or pdksh (a poor imitation, IMO)?

Posting Permissions

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