Sponsored Content
Full Discussion: Decimal places
Top Forums Shell Programming and Scripting Decimal places Post 302516752 by kevintse on Monday 25th of April 2011 02:37:37 AM
Old 04-25-2011
Use bc:
Code:
echo "236 * 1.00" | bc

Use awk:
Code:
awk 'BEGIN{p=236 * 1.00; printf "%0.2f", p}'

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

trimm up the decimal places in output

I have a perl script that reports the avg time of a application call and the total number of calls. This works fine, however I would like to trim the number of decimal places reported from 12 to like 3 and I don't know how. Any suggestions? Here is what I use to get the avg time... for $eRef (... (2 Replies)
Discussion started by: theninja
2 Replies

2. Shell Programming and Scripting

Using the "Less Than" (-lt) switch on numbers with decimal places?

I'm using shell scripts to run some commands for the Configuration Management tool called Telelogic Synergy. I need to get the script to compare version numbers of files. The version numbers of the files are part of the actual filename, such as the following example: example_file-1... (7 Replies)
Discussion started by: Glyn_Mo
7 Replies

3. Shell Programming and Scripting

Four decimal places with awk

i have a script in which awk prints "($2-1700)/10000" and the answer is -0.07,but i want the answer in 4 decimal places. that is -0.0700. How can i sue awk to get my results in four decimal places (4 Replies)
Discussion started by: tomjones
4 Replies

4. Shell Programming and Scripting

Arithmetic but keep 2 decimal places

I am trying to perform arithmetric, for example, to increment the value of variable $a (say 3) by 0.05 but when I tried the following expression let a=a+0.05 or a=$((a+0.05)) both returned 3.0499999999999998 I want to keep 2 decimal places so it returns 3.05 instead. (6 Replies)
Discussion started by: piynik
6 Replies

5. Shell Programming and Scripting

Bash Rounding to 2 decimal places

I have a number in a bash variable n, and want to round it to 2 decimal places. How can I do that? n=0.0867268 Need to have num=0.09 (1 Reply)
Discussion started by: kristinu
1 Replies

6. Shell Programming and Scripting

How to round up value upto 2 decimal places using sed?

Please help me in rounding up value upto 2 decimal palces using sed command #!/usr/bin/bash a=15.42 b=13.33 c=`echo $a*$b |bc -l` echo $c above code is is giving output "205.5486" but i want the output as "205.55" Thank you... (15 Replies)
Discussion started by: ranabhavish
15 Replies

7. Shell Programming and Scripting

Printing with decimal places from last 4 digits

I have input file like below, 201424|9999|OSS|622010|RGT|00378228764 201424|8888|OM|587079|RGT|00284329675 201424|7777|OM|587076|RGT|00128671024 201424|6666|OM|581528|RGT|00113552084 Output should be like below, should add decimal (.) from last 4 digits. ... (2 Replies)
Discussion started by: vinothsekark
2 Replies

8. Shell Programming and Scripting

Sum the fields with 6 decimal places - getting only 2 decimal places as output

I used the below script to Sum up a field in a file based on some unique values. But the problem is when it is summing up the units, it is truncating to 2 decimals and not 6 decimals as in the input file (Input file has the units with up to 6 Decimals – Sample data below, when the units in the 2... (4 Replies)
Discussion started by: brlsubbu
4 Replies

9. Shell Programming and Scripting

Calculate the constant e to 14+ decimal places using integer maths.

Hi guys... I am loving this integer maths thing. 64 bit systems are certainly easier than 32 bit, but hey, I don't intend to leave out my fav' platform. Using one of the 'Brothers' methods, URL inside the code. #!/bin/sh # # #!/usr/local/bin/dash # e_constant.sh # Brother's formula . #... (2 Replies)
Discussion started by: wisecracker
2 Replies
iconv_1250(5)						Standards, Environments, and Macros					     iconv_1250(5)

NAME
iconv_1250 - code set conversion tables for MS 1250 (Windows Latin 2) DESCRIPTION
The following code set conversions are supported: +----------------------------------------------------------------------+ | Code Set Conversions Supported | +-------------+----------+--------------+----------+-------------------+ | Code | Symbol | Target Code | Symbol | Target Output | +-------------+----------+--------------+----------+-------------------+ |MS 1250 | win2 | ISO 8859-2 |iso2 |ISO Latin 2 | +-------------+----------+--------------+----------+-------------------+ |MS 1250 | win2 | MS 852 |dos2 |MS-DOS Latin 2 | +-------------+----------+--------------+----------+-------------------+ |MS 1250 | win2 | Mazovia |maz |Mazovia | +-------------+----------+--------------+----------+-------------------+ |MS 1250 | win2 | DHN |dhn |Dom Handlowy Nauki | +-------------+----------+--------------+----------+-------------------+ CONVERSIONS
The conversions are performed according to the following tables. All values in the tables are given in octal. MS 1250 to ISO 8859-2 For the conversion of MS 1250 to ISO 8859-2, all characters not in the following table are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | MS 1250 | ISO 8859-2 | MS 1250 | ISO 8859-2 | |24-211 | 40 |235 |273 | |212 | 251 |236 |276 | |213 | 40 |237 |274 | |214 | 246 |241 |267 | |215 | 253 |245 |241 | |216 | 256 |246-267 |40 | |217 | 254 |271 |261 | |221-231 | 40 |273 |40 | |232 | 271 |274 |245 | |233 | 40 |276 |265 | |234 | 266 |247 |365 | +---------------+----------------+----------------+---------------+ MS 1250 to MS 852 For the conversion of MS 1250 to MS 852, all characters not in the following table are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | MS 1250 | MS 852 | MS 1250 | MS 852 | |200-211 | 40 |311 |220 | |212 | 346 |312 |250 | |213 | 40 |313 |323 | |214 | 227 |314 |267 | |215 | 233 |315 |326 | |216 | 246 |316 |327 | |217 | 215 |317 |322 | |220-231 | 40 |320 |321 | |232 | 347 |321 |343 | |233 | 40 |322 |325 | |234 | 230 |323 |340 | |235 | 234 |324 |342 | |236 | 247 |325 |212 | |237 | 253 |326 |231 | |240 | 377 |327 |236 | |241 | 363 |330 |374 | |242 | 364 |331 |336 | |243 | 235 |332 |351 | |244 | 317 |333 |353 | |245 | 244 |334 |232 | |246 | 40 |335 |355 | |247 | 365 |336 |335 | |250 | 371 |337 |341 | |251 | 40 |340 |352 | |252 | 270 |341 |240 | |253 | 256 |342 |203 | |254 | 252 |343 |307 | |255 | 360 |344 |204 | |256 | 40 |345 |222 | |257 | 275 |346 |206 | |260 | 370 |347 |207 | |261 | 40 |350 |237 | |262 | 362 |351 |202 | |263 | 210 |352 |251 | |264 | 357 |353 |211 | |265-267 | 40 |354 |330 | |270 | 367 |355 |241 | |271 | 245 |356 |214 | |272 | 255 |357 |324 | |273 | 257 |360 |320 | |274 | 225 |361 |344 | |275 | 361 |362 |345 | |276 | 226 |363 |242 | |277 | 276 |364 |223 | |300 | 350 |365 |213 | |301 | 265 |366 |224 | |302 | 266 |367 |366 | |303 | 306 |370 |375 | |304 | 216 |371 |205 | |305 | 221 |372 |243 | |306 | 217 |374 |201 | |307 | 200 |375 |354 | |310 | 254 |376 |356 | +---------------+----------------+----------------+---------------+ MS 1250 to Mazovia For the conversion of MS 1250 to Mazovia, all characters not in the following table are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | MS 1250 | Mazovia | MS 1250 | Mazovia | |200-213 | 40 |310-311 |40 | |214 | 230 |312 |220 | |215-216 | 40 |313-320 |40 | |217 | 240 |321 |245 | |220-233 | 40 |322 |40 | |234 | 236 |323 |243 | |235-236 | 40 |324-325 |40 | |237 | 246 |326 |231 | |240 | 377 |327-333 |40 | |241-242 | 40 |334 |232 | |243 | 234 |335-336 |40 | |244 | 40 |337 |341 | |245 | 217 |340-341 |40 | |246-252 | 40 |342 |203 | |253 | 256 |343 |40 | |254 | 252 |344 |204 | |255-256 | 40 |345 |40 | |257 | 241 |346 |215 | |260 | 370 |347 |207 | |261 | 361 |350 |40 | |262 | 40 |351 |202 | |263 | 222 |352 |221 | |264 | 40 |353 |211 | |265 | 346 |354-355 |40 | |266 | 40 |356 |214 | |267 | 372 |357-360 |40 | |270 | 40 |361 |244 | |271 | 206 |362 |40 | |272 | 40 |363 |242 | |273 | 257 |364 |223 | |274-276 | 40 |365 |40 | |277 | 247 |366 |224 | |300-303 | 40 |367 |366 | |304 | 216 |370-373 |40 | |305 | 40 |374 |201 | |306 | 225 |375-376 |40 | |307 | 200 | | | +---------------+----------------+----------------+---------------+ MS 1250 to DHN For the conversion of MS 1250 to DHN, all characters not in the following table are mapped unchanged. +-----------------------------------------------------------------+ | | Conversions|Performed | | | MS 1250 | DHN | MS 1250 | DHN | |200-213 | 40 |306 |201 | |214 | 206 |307-311 |40 | |215-216 | 40 |312 |202 | |217 | 207 |313-320 |40 | |220-233 | 40 |321 |204 | |234 | 217 |322 |40 | |235-236 | 40 |323 |205 | |237 | 220 |324-325 |40 | |240 | 377 |326 |231 | |241-242 | 40 |327-333 |40 | |243 | 203 |334 |232 | |244 | 40 |335-336 |40 | |245 | 200 |337 |341 | |246-252 | 40 |340 |40 | |253 | 256 |341 |240 | |254 | 252 |342-345 |40 | |255-256 | 40 |346 |212 | |257 | 210 |347-351 |40 | |260 | 370 |352 |213 | |261 | 361 |353-354 |40 | |262 | 40 |355 |241 | |263 | 214 |356-360 |40 | |264 | 40 |361 |215 | |265 | 346 |362 |40 | |266 | 40 |363 |216 | |267 | 372 |364 |223 | |270 | 40 |365 |40 | |271 | 211 |366 |224 | |272 | 40 |367 |366 | |273 | 257 |370-371 |40 | |274-276 | 40 |372 |243 | |277 | 221 |373-376 |40 | |300-305 | 40 | | | +---------------+----------------+----------------+---------------+ FILES
/usr/lib/iconv/*.so conversion modules /usr/lib/iconv/*.t conversion tables /usr/lib/iconv/iconv_data list of conversions supported by conversion tables SEE ALSO
iconv(1), iconv(3C), iconv(5) SunOS 5.10 18 Apr 1997 iconv_1250(5)
All times are GMT -4. The time now is 07:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy