# Crimson Editor – Help Topics – Built-in Calculator Crimson Editor is equiped with a calculator that can evaluate simple expressions. If you want to calculate a simple expression, use Crimson Editor built-in calculator to get the answer quickly. Usage Examples Following examples show how to use Crimson Editor built-in calculator: Type in the expression you want to evaluate in Crimson Editor. The whole expression should be written in one line. Press Ctrl+Enter to calculate the expression when the caret is in the line of expression. Example: 3.14 * (2.43 + 0.91) <– press Ctrl+Enter when the caret is in the expression line = 10.487600 <– you will get the answer immediately There are two special variables in Crimson Editor calculator: $ans – If you want to use the value that was evaluated in the earler step, use a special variable named $ans. $pi – The value of the variable $pi is 3.1415926535. Example: $ans / $pi = 3.338307 Crimson Editor supports basic mathematics functions which are very similar to those used in C math library. Example: sin(1.2) + atan2(3.2, 4.3) = 1.571809 Following list shows basic mathematics functions supported by Crimson Editor: abs, fabs, mod, fmod, ceil, floor, round, min, max, acos, asin, atan, atan2, cos, sin, tan, cosh, sinh, tanh, exp, log, log10, pow, sqr, sqrt Date functions, those are frequently used in financial problems, are now available in Crimson Editor 3.45. Following list shows date functions supported by Crimson Editor: today, yeardays, monthdays, date2days, days2date, eomday, eomdate, weekday, isbizdate, nbizdate, pbizdate, adddays, addmonths, addterms, days360, days365, daysact, daysbet, monthsbet, termsbet, termfrac, yearfrac Mathematics Functions
abs, fabs | fabs(x) - absolute value functions returns the absolute value of x, |x|.
mod, fmod | fmod(x, y) - remainder functions returns the remainder f of the division of x by y, where f has the same sign as x, such that x=iy+f for some integer i, and |f| < |y|.
ceil | ceil(x) - ceiling function returns the smallest integer not less than x.
floor | floor(x) - floor function returns the largest integer not greater than x.
round | round(x) - round function rounds its argument to the nearest integral value.
min | min(x, y) - minimum returns the minimum of a pair of values
max | max(x, y) - maximum returns the maximum of a pair of values
acos | acos(x) - arccosine function returns the arccosine of x in the range 0 to pi.
asin | asin(x) - arcsine function returns the arcsine of x in the range -pi/2 to pi/2.
atan | atan(x) - arctangent function returns the arctangent of x in the range -pi/2 to pi/2.
atan2 | atan2(y, x) - arctangent-and-quadrant function returns the arctangent of y/x, in the range -pi to pi, using the signs of both arguments to determine the quadrant of the return value.
cos | cos(x) - cosine function returns the cosine of x (x specified in radians).
sin | sin(x) - sine function returns the sine of x (x specified in radians).
tan | tan(x) - tangent function returns the tangent of x (x specified in radians).
cosh | cosh(x) - hyperbolic cosine function returns the hyperbolic cosine of its argument.
sinh | sinh(x) - hyperbolic sine function returns the hyperbolic sine of its argument.
tanh | tanh(x) - hyperbolic tangent function returns the hyperbolic tangent of its argument.
exp | exp(x) - exponential function returns e^x.
log | log(x) - natural logarithm function returns the natural logarithm of x. The value of x must be greater than zero.
log10 | log10(x) - common logarithm function returns the logarithm base ten of x. The value of x must be greater than zero.
pow | pow(x, y) - power function returns x^y. If x is negative, y must be an integer value.
sqr | sqr(x) - square function returns x*x.
sqrt | sqrt(x) - square root function returns the non-negative square root of x. The value of x must not be less than zero.
Date Functions
today | today() - current date returns the current date as a number. i.g. 20020807 (Aug. 07, 2002)
yeardays | yeardays(year) - number of days in a year returns the actual number of days in the given year.
monthdays | monthdays(year, month) - number of days in a month returns the actual number of days in the given month.
date2days | date2days(date) - date to serial date number conversion returns the number of days to the given date since the Epoch.
days2date | days2date(date) - serial date number to date conversion date2days(date) returns the date calculated from the given number of days since the Epoch.
eomday | eomday(year, month) - last day of month returns the last day of the month for the given year and month.
eomdate | eomdate(year, month) - last date of month returns the last date of the month for the given year and month.
weekday | weekday(date) - day of the week returns the day of the week in numeric form. weekday: 0 = Sun 1 = Mon 2 = Tue 3 = Wed 4 = Thu 5 = Fri 6 = Sat
isbizdate | isbizday(date) - true for date that is business day returns 1 if date is a business day and 0 otherwise.
nbizdate | nbizdate(date) - next business day returns the date of the next business day from the reference date.
pbizdate | pbizdate(date) - previous business day returns the date of the previous business day from the reference date.
adddays | adddays(date, days) - date added by given days returns the reference date added by given days.
addmonths | addmonths(date, months, end_month) - date added by given months returns the reference date added by given months. end_month: 0 = actual 1 = end month
addterms | addterms(date, terms, frequency, end_month) - date added by given terms returns the reference date added by given terms. frequency: 1 = annual 2 = semiannual 4 = quarterly 6 = bimonthly 12 = monthly end_month: 0 = actual 1 = end month
days360 | days360(start_date, end_date, european) - days between dates based on 360-day year returns the number of days between start_date and end_date based on a 360-day year. european: 0 = american 1 = european
days365 | days365(start_date, end_date) - days between dates based on 365-day year returns the number of days between start_date and end_date based on a 365-day year.
daysact | daysact(start_date, end_date) - actual number of days between dates returns the actual number of days between two dates.
daysbet | daysbet(start_date, end_date, basis) - days between dates for any day-count basis returns the number of days between start_date and end_date using the given day-count basis. basis: 0 = actual/actual 1 = actual/360 2 = actual/365 3 = 30/360 4 = 30E/360 5 = NL/365
monthsbet | monthsbet(start_date, end_date) - months between dates returns the number of months between start_date and end_date.
termsbet | termsbet(start_date, end_date, frequency) - terms between dates returns the number of terms between start_date and end_date. frequency: 1 = annual 2 = semiannual 4 = quarterly 6 = bimonthly 12 = monthly
termfrac | termfrac(start_date, end_date, frequency, basis, end_month)- fraction of term between dates returns a fraction based on the number of days between start_date and end_date using the given day-count basis. frequency: 1 = annual 2 = semiannual 4 = quarterly 6 = bimonthly 12 = monthly basis: 0 = actual/actual 1 = actual/360 2 = actual/365 3 = 30/360 4 = 30E/360 5 = NL/365 end_month: 0 = actual 1 = end month
yearfrac | yearfrac(start_date, end_date, basis, end_month) - fraction of year between dates returns a fraction based on the number of days between start_date and end_date using the given day-count basis. basis: 0 = actual/actual 1 = actual/360 2 = actual/365 3 = 30/360 4 = 30E/360 5 = NL/365 end_month: 0 = actual 1 = end month

Copyright © 1999-2006 by Ingyu Kang, Copyright © 2006-2007 by Emerald Editor Community. All rights reserved.