p.s. yes, that initial cat could have been replaced, it is merely the way I proceeded to solve this puzzle by slowly transforming the output. Try the command out piece by piece, and you will see how the data is slowly transformed to the requested output layout.
i would like to ask how to make a script that in evry 3 lines of my paragraph(below) it would appear like this:
$ cat myparagraph
this is line 1
this is line 2
this is line3
this is line 4
this is 5
this 6
this is 7
this 8
====================================================
$ cat... (2 Replies)
Hi All,
I want to run 5 `ps -ef | grep ` cmds in one script and i want the script to give me return code 0 if everything is OK. If it notices one of the processes is not there, it will prompt me the process name and advice me to check it.
I've wrote a script that separates the output but I want... (2 Replies)
I am interested in finding out if there is a reliable and economical way for extracting user's location based on his ip address, using php
I tried to get the job done using ip2location.com, but I am not happy how it deals with result inconsistently. (2 Replies)
I'm trying to read a bunch of log files and output the lines that contain particular strings.
To accomplish this, I've been running the following from the command line:
find . -name "*" | xargs grep " " | grep " " > output.txt
Two grep statements are needed in case I'm looking for a... (3 Replies)
Hello gurus,
I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script.
i m looking for something like this
call 3.1;
If 3.1 = "complete" then
call 3.2;
if 3.2 = ''COMPlete" then
call 3.3;
else
exit
The... (1 Reply)
I want to detect key pressed in my .cgi web page, but it does not work even I found the code in other web site.
My code is :
#!/bin/sh
#=================================================
# PATH defination
# ================================================... (2 Replies)
I have to check daily 20 processes each day. The names are like Network1 Network2 Network3 ....... Network20.
There is built in utility for doing this. Following is the command to check a single network process.
check_process_status 1
If we want to check the status of Network2 then the... (6 Replies)
In the reference section of a research paper(in pdf form), many other paper names are cited which have been used inside the pdf at different places. If I give an input, the name of a paper which has been cited in the reference section and want to display the section (the paragraph) inside the pdf... (1 Reply)
Hi All,
I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them
abc.sh
----------
export Numbr_Parms=$#
export a=1
while
do
export... (3 Replies)
I wish to print my current shell which happens to be bash in my script check.sh
more check.sh
echo $0
echo `ps -p $$`
But instead of printing it prints check.sh i.e the name of the script for both the commands.
Can you please suggest how to print the current shell i m on inside the... (2 Replies)
Discussion started by: mohtashims
2 Replies
LEARN ABOUT OSX
fuzzy
math::fuzzy(n) Tcl Math Library math::fuzzy(n)
__________________________________________________________________________________________________________________________________________________NAME
math::fuzzy - Fuzzy comparison of floating-point numbers
SYNOPSIS
package require Tcl ?8.3?
package require math::fuzzy ?0.2?
::math::fuzzy::teq value1 value2
::math::fuzzy::tne value1 value2
::math::fuzzy::tge value1 value2
::math::fuzzy::tle value1 value2
::math::fuzzy::tlt value1 value2
::math::fuzzy::tgt value1 value2
::math::fuzzy::tfloor value
::math::fuzzy::tceil value
::math::fuzzy::tround value
::math::fuzzy::troundn value ndigits
_________________________________________________________________DESCRIPTION
The package Fuzzy is meant to solve common problems with floating-point numbers in a systematic way:
o Comparing two numbers that are "supposed" to be identical, like 1.0 and 2.1/(1.2+0.9) is not guaranteed to give the intuitive
result.
o Rounding a number that is halfway two integer numbers can cause strange errors, like int(100.0*2.8) != 28 but 27
The Fuzzy package is meant to help sorting out this type of problems by defining "fuzzy" comparison procedures for floating-point numbers.
It does so by allowing for a small margin that is determined automatically - the margin is three times the "epsilon" value, that is three
times the smallest number eps such that 1.0 and 1.0+$eps canbe distinguished. In Tcl, which uses double precision floating-point numbers,
this is typically 1.1e-16.
PROCEDURES
Effectively the package provides the following procedures:
::math::fuzzy::teq value1 value2
Compares two floating-point numbers and returns 1 if their values fall within a small range. Otherwise it returns 0.
::math::fuzzy::tne value1 value2
Returns the negation, that is, if the difference is larger than the margin, it returns 1.
::math::fuzzy::tge value1 value2
Compares two floating-point numbers and returns 1 if their values either fall within a small range or if the first number is larger
than the second. Otherwise it returns 0.
::math::fuzzy::tle value1 value2
Returns 1 if the two numbers are equal according to [teq] or if the first is smaller than the second.
::math::fuzzy::tlt value1 value2
Returns the opposite of [tge].
::math::fuzzy::tgt value1 value2
Returns the opposite of [tle].
::math::fuzzy::tfloor value
Returns the integer number that is lower or equal to the given floating-point number, within a well-defined tolerance.
::math::fuzzy::tceil value
Returns the integer number that is greater or equal to the given floating-point number, within a well-defined tolerance.
::math::fuzzy::tround value
Rounds the floating-point number off.
::math::fuzzy::troundn value ndigits
Rounds the floating-point number off to the specified number of decimals (Pro memorie).
Usage:
if { [teq $x $y] } { puts "x == y" }
if { [tne $x $y] } { puts "x != y" }
if { [tge $x $y] } { puts "x >= y" }
if { [tgt $x $y] } { puts "x > y" }
if { [tlt $x $y] } { puts "x < y" }
if { [tle $x $y] } { puts "x <= y" }
set fx [tfloor $x]
set fc [tceil $x]
set rounded [tround $x]
set roundn [troundn $x $nodigits]
TEST CASES
The problems that can occur with floating-point numbers are illustrated by the test cases in the file "fuzzy.test":
o Several test case use the ordinary comparisons, and they fail invariably to produce understandable results
o One test case uses [expr] without braces ({ and }). It too fails.
The conclusion from this is that any expression should be surrounded by braces, because otherwise very awkward things can happen if you
need accuracy. Furthermore, accuracy and understandable results are enhanced by using these "tolerant" or fuzzy comparisons.
Note that besides the Tcl-only package, there is also a C-based version.
REFERENCES
Original implementation in Fortran by dr. H.D. Knoble (Penn State University).
P. E. Hagerty, "More on Fuzzy Floor and Ceiling," APL QUOTE QUAD 8(4):20-24, June 1978. Note that TFLOOR=FL5 took five years of refereed
evolution (publication).
L. M. Breed, "Definitions for Fuzzy Floor and Ceiling", APL QUOTE QUAD 8(3):16-23, March 1978.
D. Knuth, Art of Computer Programming, Vol. 1, Problem 1.2.4-5.
BUGS, IDEAS, FEEDBACK
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math ::
fuzzy of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may
have for either package and/or documentation.
KEYWORDS
floating-point, math, rounding
CATEGORY
Mathematics
math 0.2 math::fuzzy(n)