diff --git a/CHANGELOG b/CHANGELOG index 758fb8b..06b80ea 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,114 +1,114 @@ -Version 0.8.3 prerelease - * fixed: calculating the size of the main window - now it looks good on MS Vista and when a user changes size of some - widgets such as a border, font size, etc. - * changed: variables and functions are case-sensitive now, e.g. - 'x' is not the same as 'X' - * changed: precision: - small - the same as previous - medium - 288 bits for the mantissa, 64 bits for the exponent - big - 864 bits for the mantissa, 128 bits for the exponent - previous were: - medium - 192 bits for the mantissa, 64 bits for the exponent - big - 288 bits for the mantissa, 96 bits for the exponent - * added: when a user presses CTRL+C then the result will be - copied into the clipboard (if the current control which - has a focus is not an edit control, or if it is an edit - but has no selection) - * added: when a user presses CTRL+V then the text from the clipboard - will be copied into the edit control - (the focus can be anywhere but it cannot be on another edit control) - * added: 'decimal point' option on the display tab - * added: variables and functions can have underline characters - in their names - * added: from TTMath 0.8.3: a short form of multiplication - (without the '*' character) e.g. '5y' - (it's used only if the second parameter is a variable - or function) - * added: 'remove trailing zeroes' option on 'display' tab - * added: new language: spanish - translation made by Alejandro S. Valdezate - alesanval at gmail dot com - * added: spanish language to the setup (installer) - * added: the setup will remove mingwm10.dll if it exists in the program - directory - * added: on display tab: we can select 'deg' 'rad' or 'grad' for calculating - in such functions: sin,cos,tan,cot,asin,acos,atan,acot - * removed: 'cut off last non valid digits' on 'rounding' option - on 'display' tab - - -Version 0.8.2 portable (2007.07.01): - * added: the portable version of the program TTCalc - it uses *.ini config file from the same folder where - is the executable file, and it's much smaller in size - (in the portable version there's only one kind - of precision and the program is packed with UPX - - the Ultimate Packer for eXecutables) - there are no other differences between version 0.8.1 and this one - - -Version 0.8.1 (2007.04.17): - * changed: on win9x the configuration file is in a folder like: - "c:\windows\data application\ttcalc\" now - * changed: the program uses the TTMath 0.8.1 now - * added: from TTMath 0.8.1: - root(x, index), bitand(x,y), bitor(x,y), bitxor(x,y) - /band(x,y), bor(x,y), bxor(x,y)/ - asinh(x), acosh(x), atanh(x), acoth(x) /atgh(x), actgh(x)/ - * changed: from TTMath 0.8.1: calculations are much faster now - especially the factorial() function - * changed: from TTMath 0.8.1: the way of parsing operators - - -Version 0.8.0 (2007.04.02): - * added: the del key deletes a variable or a function now - (if the focus is on the list) - * added: a user can change the names of variables or functions now - * changed: the program uses TTMath 0.8.0 now - * added: functions: from TTMath 0.8.0: - DegToDeg(deg, min, sec), DegToRad(deg), DegToRad(deg, min, sec), - RadToDeg(rad), Ceil(x), Floor(x), Sqrt(x), Sinh(x), Cosh(x), - Tanh(x) /Tgh(x)/, Coth(x) /Ctgh(x)/ - * added: help - * changed: from TTMath 0.8.0: - renamed: CTan() into Cot() or Ctg() - renamed: ACTan() into ACot() or ACtg() - Factorial() has a history log now (it can remember last - 10 calculated values) - * fixed: the vertical size of the main window when a user uses a different - size of the window caption (especially under the Windows XP Luna) - * fixed: on Windows 9x: the program hung when a user clicks on a control - on the first tab - * fixed: when a user started navigating from the keyboard the program showed - a wrong variable or a funtion in the edit dialog - - -Version 0.7.3 (2007.03.08): - * added: the program shows some kind of errors itself - * added: checking whether an user has inserted a correct value of a variable - or a function - * fixed: navigation from the keyboard - * changed: the esc key selects the entire input text now (in the input edit) - * added: a test when the program is being starded which checks if the - coordinates of the main window actually pointing at the valid area (for - example when someone took his configuration file into a new computer and - the new computer has a smaller screen) - - -Version 0.7.2 (2007.02.28): - * added: buttons Sgn and Mod - * changed: the button 'err' is active when there's actually an error now - * added: buttons: ASin, ACos, ATan, ACTan - * fixed: the program didn't save the current language into the configuration file - * fixed: the second thread didn't read the main window correctly and it caused - small problems when an user was typing into the first edit control - - -Version 0.7.1 (2007.02.08): - * added: button 'err' (error) on the first tab - * changed: the input edit can have 2048 characters now - * added: remembering the vertical size into the config file - * fixed: a problem with the 'tab' key - * added: a message 'Calculating...' when an user clicks on the 'err' button - during calculating something +Version 0.8.3 prerelease + * fixed: calculating the size of the main window + now it looks good on MS Vista and when a user changes size of some + widgets such as a border, font size, etc. + * changed: variables and functions are case-sensitive now, e.g. + 'x' is not the same as 'X' + * changed: precision: + small - the same as previous + medium - 288 bits for the mantissa, 64 bits for the exponent + big - 864 bits for the mantissa, 128 bits for the exponent + previous were: + medium - 192 bits for the mantissa, 64 bits for the exponent + big - 288 bits for the mantissa, 96 bits for the exponent + * added: when a user presses CTRL+C then the result will be + copied into the clipboard (if the current control which + has a focus is not an edit control, or if it is an edit + but has no selection) + * added: when a user presses CTRL+V then the text from the clipboard + will be copied into the edit control + (the focus can be anywhere but it cannot be on another edit control) + * added: 'decimal point' option on the display tab + * added: variables and functions can have underline characters + in their names + * added: from TTMath 0.8.3: a short form of multiplication + (without the '*' character) e.g. '5y' + (it's used only if the second parameter is a variable + or function) + * added: 'remove trailing zeroes' option on 'display' tab + * added: new language: spanish + translation made by Alejandro S. Valdezate + alesanval at gmail dot com + * added: spanish language to the setup (installer) + * added: the setup will remove mingwm10.dll if it exists in the program + directory + * added: on display tab: we can select 'deg' 'rad' or 'grad' for calculating + in such functions: sin,cos,tan,cot,asin,acos,atan,acot + * removed: 'cut off last non valid digits' on 'rounding' option + on 'display' tab + + +Version 0.8.2 portable (2007.07.01): + * added: the portable version of the program TTCalc + it uses *.ini config file from the same folder where + is the executable file, and it's much smaller in size + (in the portable version there's only one kind + of precision and the program is packed with UPX - + the Ultimate Packer for eXecutables) + there are no other differences between version 0.8.1 and this one + + +Version 0.8.1 (2007.04.17): + * changed: on win9x the configuration file is in a folder like: + "c:\windows\data application\ttcalc\" now + * changed: the program uses the TTMath 0.8.1 now + * added: from TTMath 0.8.1: + root(x, index), bitand(x,y), bitor(x,y), bitxor(x,y) + /band(x,y), bor(x,y), bxor(x,y)/ + asinh(x), acosh(x), atanh(x), acoth(x) /atgh(x), actgh(x)/ + * changed: from TTMath 0.8.1: calculations are much faster now + especially the factorial() function + * changed: from TTMath 0.8.1: the way of parsing operators + + +Version 0.8.0 (2007.04.02): + * added: the del key deletes a variable or a function now + (if the focus is on the list) + * added: a user can change the names of variables or functions now + * changed: the program uses TTMath 0.8.0 now + * added: functions: from TTMath 0.8.0: + DegToDeg(deg, min, sec), DegToRad(deg), DegToRad(deg, min, sec), + RadToDeg(rad), Ceil(x), Floor(x), Sqrt(x), Sinh(x), Cosh(x), + Tanh(x) /Tgh(x)/, Coth(x) /Ctgh(x)/ + * added: help + * changed: from TTMath 0.8.0: + renamed: CTan() into Cot() or Ctg() + renamed: ACTan() into ACot() or ACtg() + Factorial() has a history log now (it can remember last + 10 calculated values) + * fixed: the vertical size of the main window when a user uses a different + size of the window caption (especially under the Windows XP Luna) + * fixed: on Windows 9x: the program hung when a user clicks on a control + on the first tab + * fixed: when a user started navigating from the keyboard the program showed + a wrong variable or a funtion in the edit dialog + + +Version 0.7.3 (2007.03.08): + * added: the program shows some kind of errors itself + * added: checking whether an user has inserted a correct value of a variable + or a function + * fixed: navigation from the keyboard + * changed: the esc key selects the entire input text now (in the input edit) + * added: a test when the program is being starded which checks if the + coordinates of the main window actually pointing at the valid area (for + example when someone took his configuration file into a new computer and + the new computer has a smaller screen) + + +Version 0.7.2 (2007.02.28): + * added: buttons Sgn and Mod + * changed: the button 'err' is active when there's actually an error now + * added: buttons: ASin, ACos, ATan, ACTan + * fixed: the program didn't save the current language into the configuration file + * fixed: the second thread didn't read the main window correctly and it caused + small problems when an user was typing into the first edit control + + +Version 0.7.1 (2007.02.08): + * added: button 'err' (error) on the first tab + * changed: the input edit can have 2048 characters now + * added: remembering the vertical size into the config file + * fixed: a problem with the 'tab' key + * added: a message 'Calculating...' when an user clicks on the 'err' button + during calculating something diff --git a/COPYRIGHT b/COPYRIGHT index 0e1660a..7bc877f 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,28 +1,28 @@ -Copyright (c) 2006-2009, Tomasz Sowa -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name Tomasz Sowa nor the names of contributors to this - project may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) 2006-2009, Tomasz Sowa +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name Tomasz Sowa nor the names of contributors to this + project may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README b/README index 2055703..b4e70f2 100644 --- a/README +++ b/README @@ -1,19 +1,22 @@ -TTCalc - -TTCalc is an open source mathematical calculator. It features arithmetical -functions, trigonometric functions, inverse trigonometric functions, -hyperbolic functions, inverse hyperbolic functions, logical operators, -logarithms, functions for converting between degrees and radians and -so on. Additionally the program allows a user to define his own -variables and functions. - -The program possess an easy to use interface. Calculations are performed -by using floating point numbers with three kind of precision, the biggest -has 864 bits for its mantissa and 128 bits for its exponent that is about -6.7....e+51217599719369681875006054625051616609 with 258 valid decimal digits. -TTCalc independently allows to insert and display values with the base -(radix) from two to sixteen. - -Author: Tomasz Sowa -Project page: http://ttcalc.sourceforge.net/ -Licence: BSD (open source) +TTCalc + +TTCalc is an open source mathematical calculator. It features arithmetical +functions, trigonometric functions, inverse trigonometric functions, +hyperbolic functions, inverse hyperbolic functions, logical operators, +logarithms, functions for converting between degrees and radians and +so on. Additionally the program allows a user to define his own +variables and functions. + +The program possesses an easy to use interface. Calculations are performed +by using binary floating point numbers with three kinds of precision, +the biggest has 864 bits for its mantissa and 128 bits for its exponent +that is about 6.70897699... * 10^51217599719369681875006054625051616609 +with 258 valid decimal digits. TTCalc independently allows to insert and +display values with the base (radix) from two to sixteen. + +Author: Tomasz Sowa +Contact: t.sowa@slimaczek.pl +Licence: BSD (open source) +Interface: English, Polish, Spanish +Project page: http://ttcalc.sourceforge.net/ +Operating systems: Microsoft Windows 9x/Me/NT/2000/XP/Vista diff --git a/help/accuracy.html b/help/accuracy.html new file mode 100644 index 0000000..bb07801 --- /dev/null +++ b/help/accuracy.html @@ -0,0 +1,36 @@ + + + + + + TTCalc - accuracy + + + + + + + + +

Accuracy

+ +

+TTCalc uses binary floating point numbers. It means that your input values are first +converted to a binary representation and then the calculations are performed. After +calculating the result is again converted from the binary to the decimal (you can +select the input and output format on the display tab). You must remember that not +all values can be converted from binary to decimal (and vice versa) without loosing +accuracy. For example decimal '5' can be converted to binary '101' and the '101' is +exactly equal decimal 5. But decimal '0.3' has not a good binary representation, it +is '0.010011001100110011.....'. And when you put decimal '0.3' the calculations are +performed on an approximate value and the result is only an approximation too. +

+ +

+For example try to calculate: 0.204 - 0.34*0.80 + 0.068, you would expect that the +result would be: 0 but TTCalc gives you: 3.15544362088404722164691426e-30 which is +a good approximation to the real zero (look at e-30 part which means 10^(-30)). +

+ + + diff --git a/help/arithmetic_functions.html b/help/arithmetic_functions.html index 78bd8dc..d0b2b8a 100644 --- a/help/arithmetic_functions.html +++ b/help/arithmetic_functions.html @@ -6,51 +6,7 @@ TTCalc - arithmetic functions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -60,149 +16,98 @@

Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

-
-
ln(x)
-
This function calculates the natural logarithm of x,
e.g. ln(123)=4.812...
+

Logarithm and Exponential

-
log(x; base)
-
This function calculates the logarithm of x with a base equal 'base'
log(123; 4)=3.471...
+ -
exp(x)
-
This function calculates the exponent of x
exp(20)=e^20=485165195.409...
-
sin(x)
-
This function returns the sine of x.
For example sin(0.8)=0.717...
The argument x is in radians, if you want to calculate -with degrees use the degtorad(x) function first e.g. sin(degtorad(30))=0.5 calculates the sine of 30 degrees.
+

Trigonometric functions

-
cos(x)
-
Cosine of x
cos(1.3)=0.267...
The argument x is in radians.
+

Note: On the display tab you can select between degrees, radians and gradians. This affects the input value.

-
tan(x) or tg(x)
-
Tangent of x
tan(3.6)=0.493...
The argument x is in radians.
+ -
cot(x) or ctg(x)
-
Cotangent of x
cot(2.3)=-0.893...
The argument x is in radians.
-
asin(x)
-
Inverse sine (arc sine) of x
e.g. asin(0.7)=0.775...
The result is in radians. If you want the result to be in degrees use -radtodeg function e.g. radtodeg(asin(0,5))=30
+

Inverse trigonometric functions

-
acos(x)
-
Inverse cosine (arc cosine) of x
acos(0.9)=0.451...
The result is in radians.
+

Note: On the display tab you can select between degrees, radians and gradians. This affects the output (result) value.

-
atan(x) or atg(x)
-
Inverse tangent (arc tangent) of x
atan(3.3)=1.276...
The result is in radians.
+ -
acot(x) or actg(x)
-
Inverse cotangent (arc cotangent) of x
acot(10)=0.099...
The result is in radians.
-
sinh(x)
-
This function returns hyperbolic sine of x
sinh(12)=81377.395...
+

Hyperbolic functions

-
cosh(x)
-
Hyperbolic cosine of x
cosh(8.5)=2457.384...
+ -
tanh(x) or tgh(x)
-
Hyperbolic tangent of x
tanh(0.67)=0.584...
-
coth(x) or ctgh(x)
-
Hyperbolic cotangent of x
coth(1.67)=1.073...
+

Inverse hyperbolic functions

-
asinh(x)
-
This function returns inverse hyperbolic sine of x
asinh(3.6)=1.992...
+ -
acosh(x)
-
This function returns inverse hyperbolic cosine of x
acosh(2.23)=1.440...
-
atanh(x) or atgh(x)
-
This function returns inverse hyperbolic tangent of x
atanh(0.67)=0.810...
+

Conversions between radians, degrees and gradians

-
acoth(x) or actgh(x)
-
This function returns inverse hyperbolic cotangent of x
acoth(1.23)=1.135...
+ -
DegToDeg(deg; min; sec)
-
This function converts degrees from the long format with degres, minutes and seconds into only degrees.
-For example degtodeg(12; 30; 0)=12.5
-
DegToRad(deg)
-
This function converts degrees into radians
degtorad(12.5)=0.218166...
+

Rounding functions

-
DegToRad(deg; min; sec)
-
This function converts degrees in the long format (degrees, minutes, seconds) to radians.
For example -degtorad(12; 30; 0)=0.218166...
+ -
RadToDeg(rad)
-
This function converts radians into degrees
radtodeg(pi)=180
-
sqrt(x)
-
Sqrt returns the square root of x
sqrt(9)=3
+

Other functions

-
root(x ; n)
-
The nth root of a 'x', 'n' must be integer and not negative, if 'n' is zero the result is one, -if 'x' is zero the result is zero and we assume that the root(0;0) is not defined, e.g.
-root(8;3)=2
-root(-8;3)=-2 -
- -
factorial(x)
-
The factorial function
factorial(6)=1*2*3*4*5*6=720
- -
abs(x)
-
The absolute value of x
abs(-10)=10
- -
sgn(x)
-
This function returns the sign of x that means when the x is positive the result is 1, when the x is negative -the result is -1 and when the x is zero the result is zero too
-sgn(-10)=-1
-sgn(0)=0
-sgn(5)=1
- -
mod(x,y)
-
Mod returns the remainder from the division x by y
mod(10; 2.2)=1.2 because 10=2.2*4 + 1.2
- -
int(x)
-
This method returns only the integer part of x.
int(2.7)=2
- -
round(x)
-
This method rounds the value of x to the nearest integer
-round(2.8)=3
-round(2.2)=2
-round(2)=2
-round(-4.8)=-5
-round(-4.1)=-4
- -
ceil(x)
-
This function returns a value representing the smallest integer that is greater than or equal to x
-ceil(2.8)=3
-ceil(2.2)=3
-ceil(2)=2
-ceil(-4.8)=-4
-ceil(-4.1)=-4
- -
floor(x)
-
This function returns a value representing the largest integer that is less than or equal to x
-floor(2.8)=2
-floor(2.2)=2
-floor(2)=2
-floor(-4.8)=-5
-floor(-4.1)=-5
- -
max(x1; x2; ...)
-
This functions takes any number of arguments. It returns the max value of them. If there aren't arguments -the function returns the max value which can be held in this precision.
- -
min(x1; x2; ...)
-
This functions takes any number of arguments. It returns the min value of them. If there aren't arguments -the function returns the min value which can be held in this precision.
- -
sum(x1; x2; ...)
-
This functions takes one or more arguments. It returns the sum of them.
- -
avg(x1; x2; ...)
-
This functions takes one or more arguments. It returns the arithmetic mean. (The sum divided by -the number of arguments)
- -
+ diff --git a/help/conversions_deg_rad_grad.html b/help/conversions_deg_rad_grad.html new file mode 100644 index 0000000..eb62630 --- /dev/null +++ b/help/conversions_deg_rad_grad.html @@ -0,0 +1,64 @@ + + + + + + TTCalc - Conversions between radians, degrees and gradians + + + + + + + + + + + + + + +

Arithmetic functions

+ +

Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

+ + +

Conversions between radians, degrees and gradians

+ +
+ +
degtodeg(deg; min; sec)
+
This function converts degrees from the long format with degrees, minutes and seconds to degrees.
+For example: degtodeg(12; 30; 0)=12.5
+ +
degtorad(deg; min; sec)
+
This function converts degrees in the long format (degrees, minutes, seconds) to radians.
+degtorad(12; 30; 0)=0.218166...
+ +
degtograd(deg; min; sec)
+
This function converts degrees in the long format (degrees, minutes, seconds) to gradians
degtograd(12; 30; 0)=13.888...
+ +
degtorad(deg)
+
This function converts degrees to radians
degtorad(12.5)=0.218166...
+ +
degtograd(deg)
+
This function converts degrees to gradians
degtograd(12.5)=13.8888...
+ + +
radtodeg(rad)
+
This function converts radians to degrees
radtodeg(pi)=180
+ +
radtograd(rad)
+
This function converts radians to gradians
radtograd(pi)=200
+ +
gradtorad(grad)
+
This function converts gradians to radians
gradtorad(400)=6.2831....=2*pi
+ +
gradtodeg(grad)
+
This function converts gradians to degrees
gradtodeg(100)=90
+ +
+ + + + diff --git a/help/help.hhp b/help/help.hhp index a1876cf..7572476 100644 --- a/help/help.hhp +++ b/help/help.hhp @@ -13,12 +13,21 @@ Title=TTCalc [FILES] values_and_std_operators.html arithmetic_functions.html +bitwise_functions.html +conversions_deg_rad_grad.html +hyperbolic_functions.html +index.html +inverse_hyperbolic_functions.html +inverse_trigonometric_functions.html +logarithm_exponential.html logical_functions.html operators_priority.html -userfunctions.html -index.html +other_functions.html +rounding_functions.html tips.html -bitwise_functions.html +trigonometric_functions.html +userfunctions.html +accuracy.html [INFOTYPES] diff --git a/help/hyperbolic_functions.html b/help/hyperbolic_functions.html new file mode 100644 index 0000000..6658f00 --- /dev/null +++ b/help/hyperbolic_functions.html @@ -0,0 +1,46 @@ + + + + + + TTCalc - Hyperbolic functions + + + + + + + + + + + + + +

Arithmetic functions

+ +

Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

+ + +

Hyperbolic functions

+ +
+ +
sinh(x)
+
This function returns hyperbolic sine of x
sinh(12)=81377.395...
+ +
cosh(x)
+
Hyperbolic cosine of x
cosh(8.5)=2457.384...
+ +
tanh(x) or tgh(x)
+
Hyperbolic tangent of x
tanh(0.67)=0.584...
+ +
coth(x) or ctgh(x)
+
Hyperbolic cotangent of x
coth(1.67)=1.073...
+ +
+ + + + + diff --git a/help/index.html b/help/index.html index db87aa0..06aa579 100644 --- a/help/index.html +++ b/help/index.html @@ -10,6 +10,7 @@ + @@ -20,26 +21,31 @@

TTCalc

-TTCalc is a mathematical calculator. It has a nice user interface, formulas for -calculating can be inserted by using a keyboard or a mouse. The result is automatically -shown in a second window without using any additional keys such as 'equal'. The -program possess trigonometric functions, inverse trigonometric functions, hyperbolic -functions, logical operators, logarithms, functions for converting between degrees and -radians and so on. Additionally the program allows the user to define his own -variables and functions. Calculations are performed by using floating point numbers -with three kind of precision, the biggest has 288 bits for its mantissa and 96 bits -for its exponent that is about 2.551...e+11925026709067095507636213441 with 85 valid -decimal digits. The program independently allows to insert and display values with -the base (radix) from two to sixteen. +TTCalc is an open source mathematical calculator. It features arithmetical +functions, trigonometric functions, inverse trigonometric functions, +hyperbolic functions, inverse hyperbolic functions, logical operators, +logarithms, functions for converting between degrees and radians and +so on. Additionally the program allows a user to define his own +variables and functions.

+

+The program possesses an easy to use interface. Calculations are performed +by using binary floating point numbers with three kinds of precision, +the biggest has 864 bits for its mantissa and 128 bits for its exponent +that is about 6.70897699... * 10^51217599719369681875006054625051616609 +with 258 valid decimal digits. TTCalc independently allows to insert and +display values with the base (radix) from two to sixteen. +

+ + - - - + + +
Author:Tomasz Sowa
Contact:t.sowa@slimaczek.pl
Licence:BSD (open source)
Operating systems:Microsoft Windows 9x/Me/NT/2000/XP (Vista was not tested)
Interface:English, Polish
Project page:http://sourceforge.net/projects/ttcalc
Interface:English, Polish, Spanish
Project page:http://ttcalc.sourceforge.net/
Operating systems:Microsoft Windows 9x/Me/NT/2000/XP/Vista
diff --git a/help/inverse_hyperbolic_functions.html b/help/inverse_hyperbolic_functions.html new file mode 100644 index 0000000..feaf316 --- /dev/null +++ b/help/inverse_hyperbolic_functions.html @@ -0,0 +1,47 @@ + + + + + + TTCalc - Inverse hyperbolic functions + + + + + + + + + + + + + +

Arithmetic functions

+ +

Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

+ + + +

Inverse hyperbolic functions

+ +
+ +
asinh(x)
+
This function returns inverse hyperbolic sine of x
asinh(3.6)=1.992...
+ +
acosh(x)
+
This function returns inverse hyperbolic cosine of x
acosh(2.23)=1.440...
+ +
atanh(x) or atgh(x)
+
This function returns inverse hyperbolic tangent of x
atanh(0.67)=0.810...
+ +
acoth(x) or actgh(x)
+
This function returns inverse hyperbolic cotangent of x
acoth(1.23)=1.135...
+ +
+ + + + + diff --git a/help/inverse_trigonometric_functions.html b/help/inverse_trigonometric_functions.html new file mode 100644 index 0000000..0d29d0e --- /dev/null +++ b/help/inverse_trigonometric_functions.html @@ -0,0 +1,49 @@ + + + + + + TTCalc - Inverse trigonometric functions + + + + + + + + + + + + + +

Arithmetic functions

+ +

Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

+ + +

Inverse trigonometric functions

+ +

Note: On the display tab you can select between degrees, radians and gradians. In these samples we assume that the 'rad' option is selected. +This affects the output (result) value.

+ +
+ +
asin(x)
+
Inverse sine (arc sine) of x
e.g. asin(0.7)=0.775...
+ +
acos(x)
+
Inverse cosine (arc cosine) of x
acos(0.9)=0.451...
+ +
atan(x) or atg(x)
+
Inverse tangent (arc tangent) of x
atan(3.3)=1.276...
+ +
acot(x) or actg(x)
+
Inverse cotangent (arc cotangent) of x
acot(10)=0.099...
+ +
+ + + + + diff --git a/help/logarithm_exponential.html b/help/logarithm_exponential.html new file mode 100644 index 0000000..93ce3ee --- /dev/null +++ b/help/logarithm_exponential.html @@ -0,0 +1,39 @@ + + + + + + TTCalc - Logarithm and Exponential + + + + + + + + + + +

Arithmetic functions

+ +

Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

+ +

Logarithm and Exponential

+ +
+
ln(x)
+
This function calculates the natural logarithm of x,
e.g. ln(123)=4.812...
+ +
log(x; base)
+
This function calculates the logarithm of x with a base equal 'base'
+It's using the formula: log(x; base) = ln(x) / ln(base)
+log(123; 4)=3.471...
+ +
exp(x)
+
This function calculates the exponential function of x
exp(20)=e^20=485165195.409...
+ +
+ + + + diff --git a/help/operators_priority.html b/help/operators_priority.html index f074353..041dc0c 100644 --- a/help/operators_priority.html +++ b/help/operators_priority.html @@ -16,15 +16,15 @@

Below is a list of operators priority. At the top are operators with higher precedence.

- +
- + diff --git a/help/other_functions.html b/help/other_functions.html new file mode 100644 index 0000000..9872ccd --- /dev/null +++ b/help/other_functions.html @@ -0,0 +1,87 @@ + + + + + + TTCalc - Other functions + + + + + + + + + + + + + + + + + +

Arithmetic functions

+ +

Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

+ + +

Other functions

+ +
+ +
sqrt(x)
+
Sqrt returns the square root of x
sqrt(9)=3
+ +
root(x ; n)
+
The nth root of a 'x', 'n' must be integer and not negative, if 'n' is zero the result is one, +if 'x' is zero the result is zero and we assume that the root(0;0) is not defined, e.g.
+root(8;3)=2
+root(-8;3)=-2 +
+ +
factorial(x)
+
The factorial function
factorial(6)=1*2*3*4*5*6=720
+ +
abs(x)
+
The absolute value of x
abs(-10)=10
+ +
sgn(x)
+
This function returns the sign of x that means when the x is positive the result is 1, when the x is negative +the result is -1 and when the x is zero the result is zero too
+sgn(-10)=-1
+sgn(0)=0
+sgn(5)=1
+ +
mod(x,y)
+
Mod returns the remainder from the division x by y
mod(10; 2.2)=1.2 because 10=2.2*4 + 1.2
+ + +
max(x1; x2; ...)
+
This functions takes any number of arguments. It returns the max value of them. If there aren't arguments +the function returns the max value which can be held in this precision.
+max(2;5;8;3)=8
+max()=6.97846825730330952352039893e+646457021 (assuming the small precision is selected)
+ +
min(x1; x2; ...)
+
This functions takes any number of arguments. It returns the min value of them. If there aren't arguments +the function returns the min value which can be held in this precision.
+min(45;-23;18;19)=-23
+min()=-6.97846825730330952352039893e+646457021 (assuming the small precision is selected) +
+ +
sum(x1; x2; ...)
+
This functions takes one or more arguments. It returns the sum of them.
+sum(4;2;9;3)=18 +
+ +
avg(x1; x2; ...)
+
This functions takes one or more arguments. It returns the arithmetic mean. (The sum divided by +the number of arguments)
+avg(4;2;9;3)=4.5 +
+ +
+ + + diff --git a/help/rounding_functions.html b/help/rounding_functions.html new file mode 100644 index 0000000..3cdeb42 --- /dev/null +++ b/help/rounding_functions.html @@ -0,0 +1,67 @@ + + + + + + TTCalc - Rounding functions + + + + + + + + + + + +

Arithmetic functions

+ +

Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

+ + +

Rounding functions

+ +
+ +
int(x)
+
This method returns only the integer part of x.
+int(2.8)=2
+int(2.2)=2
+int(2)=2
+int(-4.1)=-4
+int(-4.8)=-4
+
+ +
round(x)
+
This method rounds the value of x to the nearest integer
+round(2.8)=3
+round(2.2)=2
+round(2)=2
+round(-4.1)=-4
+round(-4.8)=-5
+ +
ceil(x)
+
This function returns a value representing the smallest integer that is greater than or equal to x
+ceil(2.8)=3
+ceil(2.2)=3
+ceil(2)=2
+ceil(-4.1)=-4
+ceil(-4.8)=-4
+ +
floor(x)
+
This function returns a value representing the largest integer that is less than or equal to x
+floor(2.8)=2
+floor(2.2)=2
+floor(2)=2
+floor(-4.1)=-5
+floor(-4.8)=-5
+ +
+ + + + + + + diff --git a/help/styles.css b/help/styles.css index 93a6dd1..a0fffa2 100644 --- a/help/styles.css +++ b/help/styles.css @@ -7,23 +7,33 @@ padding: 0; html, body { font-size: 14px; -font-family: Tahoma, Arial, Sans-serif; +font-family: Verdana, Tahoma, Arial, Sans-serif; } body { -margin: 0 0 20px 20px; +margin: 0 20px 20px 20px; } h1 { font-size: 2em; -font-family: Arial, Tahoma, Sans-serif; +font-family: Arial, Tahoma, Verdana, Sans-serif; margin: 1.4em 0 1em 0; } +h2 { +font-size: 1.5em; +font-family: Arial, Tahoma, Verdana, Sans-serif; +margin: 2em 0 1em 0; +} + p { margin: 1em 0 1em 0; } +dl { +margin: 3em 0 3em 0; +} + dt { font-size: 1.4em; margin-top: 1em; @@ -42,7 +52,27 @@ td { padding: 0 2em 0 0; } +table.operatorspriority { +border: 1px solid black; +border-collapse: collapse; +} +table.operatorspriority td { +border: 1px solid black; +padding: 0.5em 0.5em 0.5em 0.5em; +} + +ul { +list-style-type: none; +} +ul.tips { +list-style-type: disc; +margin-left: 3em; +} + +ul.tips li { +padding: 1em 0 1em 0; +} diff --git a/help/tips.html b/help/tips.html index e82efc0..5088ffb 100644 --- a/help/tips.html +++ b/help/tips.html @@ -20,33 +20,36 @@

Tips

-

-If you want to clear the input edit or if you want to put something in and the focus is -somewhere on the tabs just type ESC, the entire edit will be selected and have a focus. -

+ diff --git a/help/toc.hhc b/help/toc.hhc index d930afb..41f0bda 100644 --- a/help/toc.hhc +++ b/help/toc.hhc @@ -21,6 +21,40 @@ +
  • @@ -37,6 +71,10 @@ +
  • + + +
  • diff --git a/help/trigonometric_functions.html b/help/trigonometric_functions.html new file mode 100644 index 0000000..cba2896 --- /dev/null +++ b/help/trigonometric_functions.html @@ -0,0 +1,48 @@ + + + + + + TTCalc - Trigonometric functions + + + + + + + + + + + + + +

    Arithmetic functions

    + +

    Note: If a function takes more than one argument, the arguments are separated with semicolon ';'.

    + + +

    Trigonometric functions

    + +

    Note: On the display tab you can select between degrees, radians and gradians. In these samples we assume that the 'rad' option is selected. +This affects the input value.

    + +
    + +
    sin(x)
    +
    This function returns the sine of x.
    For example sin(0.8)=0.717...
    + +
    cos(x)
    +
    Cosine of x
    cos(1.3)=0.267...
    + +
    tan(x) or tg(x)
    +
    Tangent of x
    tan(3.6)=0.493...
    + +
    cot(x) or ctg(x)
    +
    Cotangent of x
    cot(2.3)=-0.893...
    + +
    + + + + diff --git a/help/userfunctions.html b/help/userfunctions.html index fa7c7e8..c270138 100644 --- a/help/userfunctions.html +++ b/help/userfunctions.html @@ -16,19 +16,24 @@

    User defined variables and functions

    -You are allowed to define your own variables and functions. As a name of a variable or a function -can be a name consists of letters, digits or an underline character but the first character must be a letter. +You are allowed to define your own variables and functions. As a name of a variable or function +can be a name consists of letters, digits or an underline character (only the first character must be a letter). From version 0.8.3 names are case-sensitive that means 'name' is not the same as 'NaMe'. For example these -are correct names: a, b, c3, MyName, etc. During defining variables and functions you can call another -variables and functions but you cannot call a variable or a function twice. Recurrence calling are not allowed. +are correct names: a, b, c3, MyName. During defining variables and functions you can call another +variables and functions.

    Functions can get maximum 9 parameters. You have to specify how many parameters your function takes and you can refer to them by using the variable 'x' with a number from 1 to 9 ('x' without a number means 'x1'). -For example you can define a function 'xy' as 'x1*x2' (of course without apostrophes), set the 'parameters' on 2 -and then put into the edit box an expression 'xy(10;20)', the result will be 200. Note that we use a semicolon -to separate arguments in a function. +For example you can define a function 'xy' as 'x1*x2' (of course without apostrophes), set the 'parameters' to '2' +and then put into the edit box expression 'xy(10;20)', the result will be '200'. Note that we use a semicolon +to separate arguments in the function. +

    + +

    +More complex example: myfunction(x) which returns sin(x) when the x is negative, 0 when the x is 0, and cos(x) when the x is greater than 0:
    +myfunction(x)='if(x==0; 0; if(x<0; sin(x); cos(x)))'

    diff --git a/help/values_and_std_operators.html b/help/values_and_std_operators.html index a8f6a40..262d48e 100644 --- a/help/values_and_std_operators.html +++ b/help/values_and_std_operators.html @@ -12,11 +12,14 @@ + + +
    @@ -24,27 +27,37 @@

    Numbers

    -You can type numbers directly using a keyboard or insert them by a mouse. This is a simple edit window, -you can use arrow keys etc. and copy&paste a text by using standard shortcuts such as CTRL+C and CTRL+V. -As the decimal point can be either a comma or a dot that means 1,234 is the same as 1.234. +

    +You can type numbers directly using your keyboard or insert them by a mouse. This is a simple edit window, +you can use arrow keys etc. and copy&paste text by using standard shortcuts such as CTRL+C and CTRL+V. +Decimal point can be either a comma or a dot that means 1,234 is the same as 1.234. +

    Standard operators

    ^
    -
    Powering
    +
    Powering, e.g.: 2^3=8
    *
    -
    Multiplication
    +
    Multiplication, e.g.: 2*3=6
    /
    -
    Division
    +
    Division, e.g.: 2/3 = 0.6666...
    +
    -
    Addition
    +
    Addition, e.g.: 2+3=5
    +Unary plus, e.g.: +2
    -
    -
    Subtraction
    +
    Subtraction, e.g.: 2-3=-1
    +Unary minus, e.g.: -2
    + +
    #
    +
    Operator for changing the base (radix) to 16 (hex), e.g.: #ff=255
    + +
    &
    +
    Operator for changing the base (radix) to 2 (bin), e.g.: -&110=-6
    diff --git a/src/Makefile.dep b/src/Makefile.dep index 43c9f25..7da4c07 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -1,6 +1,5 @@ o = resource.o calculation.o convert.o functions.o iniparser.o languages.o mainwindow.o parsermanager.o programresources.o tabs.o variables.o winmain.o - calculation.o: calculation.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h convert.o: convert.cpp convert.h compileconfig.h bigtypes.h functions.o: functions.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h @@ -20,12 +19,21 @@ winmain.o: winmain.cpp compileconfig.h winmain.h programresources.h iniparser. $(CC) -c $(CFLAGS) $< -helpdep = ../help/arithmetic_functions.html \ +helpdep = ../help/arithmetic_functions.html \ + ../help/logarithm_exponential.html \ + ../help/trigonometric_functions.html \ + ../help/inverse_trigonometric_functions.html \ + ../help/hyperbolic_functions.html \ + ../help/inverse_hyperbolic_functions.html \ + ../help/conversions_deg_rad_grad.html \ + ../help/rounding_functions.html \ + ../help/other_functions.html \ ../help/operators_priority.html \ ../help/bitwise_functions.html \ ../help/index.html \ ../help/userfunctions.html \ ../help/logical_functions.html \ + ../help/accuracy.html \ ../help/tips.html \ ../help/values_and_std_operators.html \ ../help/styles.css \ @@ -33,4 +41,4 @@ helpdep = ../help/arithmetic_functions.html \ ../help/toc.hhc \ ../help/help.hhp -setupdep = ttcalc help ../setup/innosetup.iss ../setup/COPYRIGHT +setupdep = ttcalc help ../setup/innosetup.iss ../setup/COPYRIGHT ../COPYRIGHT ../CHANGELOG ../README diff --git a/src/programresources.cpp b/src/programresources.cpp index 914236d..023a2ba 100644 --- a/src/programresources.cpp +++ b/src/programresources.cpp @@ -454,7 +454,7 @@ ProgramResources::ProgramResources() base_output = 10; display_always_scientific = false; - display_when_scientific = 15; + display_when_scientific = 8; display_rounding = -1; remove_zeroes = true; diff --git a/src/programresources.h b/src/programresources.h index 110c881..c8c2ead 100644 --- a/src/programresources.h +++ b/src/programresources.h @@ -69,10 +69,14 @@ GetPrgRes()->SetPrecision( new_precision ); GetPrgRes()->GetThreadController()->StartCalculating(); + if you change some variables by using GetVariable() method + you should call VariablesChanged() in order to inform the second thread that variables have changed + (variables_id will be increment), the same is for functions (FunctionsChanged() method) + methods which are used by the second thread: GetBuffer(), GetVariables(), GetFunctions(), GetBaseInput(), GetBaseOutput() GetDisplayAlwaysScientific(), GetDisplayWhenScientific(), GetDisplayRounding() - GetCurrentLanguage(), GetPrecision() + GetCurrentLanguage(), GetPrecision() ... and if you're using methods which begin with Set..... you must call it between StopCalculating() and StartCalculating() diff --git a/src/stopcalculating.h b/src/stopcalculating.h index 68d789e..579d426 100644 --- a/src/stopcalculating.h +++ b/src/stopcalculating.h @@ -1,159 +1,159 @@ -/* - * This file is a part of TTCalc - a mathematical calculator - * and is distributed under the (new) BSD licence. - * Author: Tomasz Sowa - */ - -/* - * Copyright (c) 2006-2008, Tomasz Sowa - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name Tomasz Sowa nor the names of contributors to this - * project may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef headerfilestopcalculating -#define headerfilestopcalculating - -/*! - \file stopcalculating.h - \brief it tells us whether there was a stop signal or not -*/ - -#include -#include - - -/*! - \brief it tells us whether there was a stop signal or not - - we can pass a pointer to the object of this class to the certain - calculating methods especially for the method which calculates the - Factorial (1*2*3*4....), such methods as the Factorial takes a lot of time - and sometimes we want to break the calculations for example when we've got - a new input string - - those methods which take a lot of time check the object of type NewStopCalculating - and if there was a stop signal they stop and return immediately without returning - a correct result - - the stop signal can be caused by another thread in our case by the first (gui) thread - - there'll be only one object of this class - (it'll be as an variable of ThreadController class) -*/ -class NewStopCalculating : public ttmath::StopCalculating -{ -public: - - - /*! - the constructor - */ - NewStopCalculating() - { - stop = 0; - } - - - /*! - the destructor - */ - ~NewStopCalculating() - { - if(stop) CloseHandle(stop); - } - - - /*! - it initializes an object of this class - - this method will be called from Init() of the ThreadController object - */ - bool Init() volatile - { - char buffer[80]; - - // with 'GetTickCount()' we're generating an unique identifier of our event - // (there can be another window of ttcalc) - sprintf(buffer,"TTCalcStopEventForStoppingCalculations7756%u", - (unsigned int)GetTickCount()); - - // 'stop' will be manual-reseted and initialized as non-signaled - if( (stop = CreateEvent(0,true,false,buffer))==NULL) - return false; - - return true; - } - - - /*! - when we want to stop the calculations for example when the user changed somewhat - we call the Stop() method from the first (gui) thread - */ - void Stop() volatile - { - SetEvent(stop); - } - - - /*! - when we start the calculations we call this method - - (we call it from WaitForCalculatingAndBlockForStop() method of - ThreadController class) - */ - void Start() volatile - { - ResetEvent(stop); - } - - - /*! - it returns 'true' if there was a stop signal - - it's useful for the second thread and functions which take plenty of time - for calculating, when this method returns 'true' those methods break the - calculations and return without returning a correct value - */ - virtual bool WasStopSignal() const volatile - { - if( WaitForSingleObject(stop,0) == WAIT_OBJECT_0 ) - return true; - - return false; - } - - -private: - -// manual-reset, initialized as non-signaled -HANDLE stop; - -}; - - -#endif +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2008, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef headerfilestopcalculating +#define headerfilestopcalculating + +/*! + \file stopcalculating.h + \brief it tells us whether there was a stop signal or not +*/ + +#include +#include + + +/*! + \brief it tells us whether there was a stop signal or not + + we can pass a pointer to the object of this class to the certain + calculating methods especially for the method which calculates the + Factorial (1*2*3*4....), such methods as the Factorial takes a lot of time + and sometimes we want to break the calculations for example when we've got + a new input string + + those methods which take a lot of time check the object of type NewStopCalculating + and if there was a stop signal they stop and return immediately without returning + a correct result + + the stop signal can be caused by another thread in our case by the first (gui) thread + + there'll be only one object of this class + (it'll be as an variable of ThreadController class) +*/ +class NewStopCalculating : public ttmath::StopCalculating +{ +public: + + + /*! + the constructor + */ + NewStopCalculating() + { + stop = 0; + } + + + /*! + the destructor + */ + ~NewStopCalculating() + { + if(stop) CloseHandle(stop); + } + + + /*! + it initializes an object of this class + + this method will be called from Init() of the ThreadController object + */ + bool Init() volatile + { + char buffer[80]; + + // with 'GetTickCount()' we're generating an unique identifier of our event + // (there can be another window of ttcalc) + sprintf(buffer,"TTCalcStopEventForStoppingCalculations7756%u", + (unsigned int)GetTickCount()); + + // 'stop' will be manual-reseted and initialized as non-signaled + if( (stop = CreateEvent(0,true,false,buffer))==NULL) + return false; + + return true; + } + + + /*! + when we want to stop the calculations for example when the user changed somewhat + we call the Stop() method from the first (gui) thread + */ + void Stop() volatile + { + SetEvent(stop); + } + + + /*! + when we start the calculations we call this method + + (we call it from WaitForCalculatingAndBlockForStop() method of + ThreadController class) + */ + void Start() volatile + { + ResetEvent(stop); + } + + + /*! + it returns 'true' if there was a stop signal + + it's useful for the second thread and functions which take plenty of time + for calculating, when this method returns 'true' those methods break the + calculations and return without returning a correct value + */ + virtual bool WasStopSignal() const volatile + { + if( WaitForSingleObject(stop,0) == WAIT_OBJECT_0 ) + return true; + + return false; + } + + +private: + +// manual-reset, initialized as non-signaled +HANDLE stop; + +}; + + +#endif
  • OperatorDescriptionSample
    ( )parentheses for grouping an expression(1+3)*4
    - + # &unary minus and plus, and operators for changing the base (radix)-10
    without an operatorshort form of multiplicating (only if the second argument is a variable or function)3y
    ^powering3^2
    * /multiplication and division10*20
    without an operatorshort form of multiplication
    (only if the second argument is a variable or function,
    the same priority as a normal multiplication)
    3y
    + -addition and subtraction10-30
    == != < > <= >=comparative operators4<5
    &&logical and3>2 && 3<10