format decimal in ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting format decimal in ksh
# 1  
Old 12-17-2008
format decimal in ksh

hi all,
in ksh, how do i format a decimal number (e.g 3381.19) to integer (e.g 3381). This number is average time response for server in millisec and i wanted to display it in a more readable format i.e in seconds without any decimals.


thanks in advance.
# 2  
Old 12-17-2008
just answered my own question, i needed to round the decimal

e.g int(3381.19 + 0.5)
# 3  
Old 12-17-2008
you must be using ksh93 to use int(). Here is a simple way to do it in all ksh versions.

Code:
$ typeset -i foo=3381.19
$ echo $foo
3381

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print hex Ip address in decimal format inside awk script

Hi to all, May someone help me with the following. The awk script below is part of a bigger awk script, and this part attempts to print an Ip address that is in hex format in decimal format. I'm trying with following code but I'm getting 0.0.0.0 and the correct answer is 192.168.140.100 ... (9 Replies)
Discussion started by: Ophiuchus
9 Replies

2. Shell Programming and Scripting

ksh Arithmetic syntax error while comparing decimal numbers

Hello, I am having a problem when i execute following script on RHEL 6.4. Same script works fine on another machine where I have same version of RHEL and KSH. Below is the rpm and RHEL version. ossvm12(0)> rpm -qa | grep ksh ksh-20100621-19.el6.x86_64 ossvm12(0)> cat... (7 Replies)
Discussion started by: Adithya Gokhale
7 Replies

3. Programming

Urgent help needed.. C++ program to convert decimal to hexa decimal

Hi , seq can be 0...128 int windex = seq / 8; int bindex = seq % 8; unsigned char bitvalue = '\x01' << (7-bindex) ; bpv.bitmapvalue = bitvalue; This is the part of a program to convert decimal to bitmap value of hexadecimal. I want this to change to convert only to... (1 Reply)
Discussion started by: greenworld123
1 Replies

4. Programming

Visual Basic converting a decimal data type to a label with currency format

Here is the code that I am working with. I have tried several other things. any suggestions? Lbl_Cost_Output.Text = (dDistance * dCostPerMile).ToString("C") The label is formatted correctly in terms of value 0.00 but no dollar sign appears. Please let me know if you have any questions. (1 Reply)
Discussion started by: briandanielz
1 Replies

5. UNIX for Dummies Questions & Answers

How to control the decimal points for p-values in scientific format?

Dear all, I have a txt file with only one column which contains p values. My data looks like this: 5.04726976606584e-190 2.94065711152402e-189 2.94065711152402e-189 9.19932135717279e-176 1.09472516659859e-170 1.24974648916809e-170 0.1223974648916 0.9874974648916 ... what I want... (2 Replies)
Discussion started by: forevertl
2 Replies

6. Shell Programming and Scripting

Awk - Summation in Proper decimal Format

Hi I am executing below command to do summation on 46th coloumn. cat File1| awk -F"|" '{p += $46} END { printf"Column Name | SUM | " p}' I am getting output as Column Name | SUM | 1.01139e+10 Here I want output in Proper decimal format. Can someone tell me what change is required for same? (1 Reply)
Discussion started by: sanranad
1 Replies

7. Homework & Coursework Questions

Unix/Linux Math Decimal to Whole Number Format?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: The problem? I hope I fill this out correctly. I have a program that runs like a cash register. It works and... (6 Replies)
Discussion started by: Iceman69
6 Replies

8. Shell Programming and Scripting

IP address to decimal format conversion

I have a file which consist of some class 4 IP address as 172.16.112.50 172.16.112.50 172.16.112.50 172.16.112.100 192.168.1.30 172.16.112.100 172.16.112.50 172.16.112.50 172.16.112.50 i want to store them in pure decimal notations instead of the given dotted decimal formats e.g.... (2 Replies)
Discussion started by: vaibhavkorde
2 Replies

9. Shell Programming and Scripting

Decimal format

Hello Friends, I have a file with below format... 1234,Hary,102.55 4567,Maria,250.40 78942,suzan,261.60 48965,Harun,179.32 And I want to check the last column. If the decimal value of the last column is below 50, I need that column else ignore that column. Can anyone help me out? (3 Replies)
Discussion started by: mziaullah
3 Replies

10. Shell Programming and Scripting

comparing two decimal values in KSH

Hi Gurus, I wrote a small KSH script, in that i am comparing two variables like this curr_time = date +%h.%m set_time=23.55 If ]; then zip the file fi The above script is croned to run evey 5(3,8,.......,58) minutes, but it is zipping at 23.03 hours. My intention is at 23.58 .what... (4 Replies)
Discussion started by: nandinisagar
4 Replies
Login or Register to Ask a Question