Page 1 of 2

Calc+

Posted: Mon Apr 21, 2014 7:42 pm
by e-andrew
Calc+ v0.3β
by e-andrew

Калькулятор, вычисляющий выражения. Пока что не особо функционален, но я над этим работаю. Хоть и присутствует кнопка ".", калькулятор работает только с целыми числами, следовательно 10/3=3.
Одной из фич является отсутствие кнопки "=". Юзер сначала удивится, а пока он будет искать эту кнопку, калькулятор всё посчитает и выведет в спец. область справа от поля ввода, которая автоматически маштабируется. Вычисления начнутся только если не вводить и не нажимать ничего в течении некоторого времени.
Используется новая таблица цветов, но не совсем корректно (win_face вместо btn_face, win_text вместо btn_text). Всё еще перерисовывается всю окно каждый раз.

Изменения в v0.3β
  • Добавлена поддержка функций
  • Добавлены функции inc(n), dec(n), abs(n), sqr(n)
Изменения в v0.2β
  • Полная поддержка (целочисленная) оператора "^" (возведения в степень) по правилам:

    Code: Select all

    -x^n == -(x^n)
    x^n^m == x^(n^m) 
  • Оптимизация. Окно больше не перерисовывается при любом изменении.
  • Изменена скорость ответа парсера.
  • Множественные багфиксы в парсере.
  • Парсер выдаёт ошибку при: (отсутствии нужного)/(наличии лишнего) оператора "(" или ")", при наличии неизвестного или неуместного символа (например "2+*3" выдаст ошибку "Input error")
На SVN: http://websvn.kolibrios.org/listing.php ... 549698486b
1.png
1.png (2.29 KiB)
Viewed 11726 times

Re: Calc+

Posted: Tue Apr 22, 2014 6:13 am
by Akyltist
отличная работа!
Почему используется win_face вместо btn_face, win_text вместо btn_text.
Таки прошу переделать потом на системные цвета, сейчас такой цвет кнопок связан со скином, если там изменить цвета , то calc , fasm, kpack и прочие программы будут иметь невнятные плохо видимые кнопки... Прошу потерпеть, все сразу не делается - но не пилить сразу не по стандарту )))

Re: Calc+

Posted: Tue Apr 22, 2014 7:39 pm
by e-andrew
Calc+ v0.2β
  • Полная поддержка (целочисленная) оператора "^" (возведения в степень) по правилам:

    Code: Select all

    -x^n == -(x^n)
    x^n^m == x^(n^m) 
  • Оптимизация. Окно больше не перерисовывается при любом изменении.
  • Изменена скорость ответа парсера.
  • Множественные багфиксы в парсере.
  • Парсер выдаёт ошибку при: (отсутствии нужного)/(наличии лишнего) оператора "(" или ")", при наличии неизвестного или неуместного символа (например "2+*3" выдаст ошибку "Input error")

Re: Calc+

Posted: Tue Apr 22, 2014 8:19 pm
by Wildwest
-x^n == -(x^n)
Тут могут быть проблемы с написанием формул. Например можно написать -1^2 и иметь в виду (-1)^2=-1*-1=1, а не -(1^2)

Re: Calc+

Posted: Tue Apr 22, 2014 8:29 pm
by e-andrew
Wildwest wrote:
-x^n == -(x^n)
Тут могут быть проблемы с написанием формул. Например можно написать -1^2 и иметь в виду (-1)^2=-1*-1=1, а не -(1^2)
Я руководствуюсь не какими то своими принципами, а конкретными правилами математики. Можно проверить "-2^2" в других калькуляторах, и там тоже будет ответ -4. Например в гугле. Если нужно возвести в квадрат -2, то нужно брать в скобки. На уроках математики нас так и учили.
Вот полезная инфа от buyerninety:
B O D M A S
Brackets (or Parentheses), Of (or Order of, or Indices, or Exponents), Division and Multiplication (equal precedence,
so work from left to right), Addition and Subtraction (equal precedence, so work from left to right)

(Some mathematical equations may give you the same answer even if you don't follow order of operations,
e.g. 1+(5x81)/9 gives same answer as 1+5x(81/9) , both cases = 46

Most mathematical equations, though, you need to follow the order of operations)
6÷2(1+2)=9 , not 1
10/2x4-5x6=-10 , not 90
15/(12+3(6-8))=2.5 , not 1.1538...

Negative Numbers;
neg x neg = pos , except in cases where zero is involved, e.g. -1 x 0 = 0
neg x neg x neg = neg

8 / -2 = -4
-16 /4 = -4
-7 x 3 / -1 = -21/-1 = 21

Pos / Neg = Neg
Neg / Pos = Neg
Neg / Neg = Pos
Pos / Pos = Pos

why is a neg divided by a neg a pos?
because it goes into it a positive number of times like -4 goes into -12 three times, right?
can also be said that, because the negatives cancel out, leaving it with a positive

if you divide or multiply negative numbers 2 times like this :
-3 x -8 x -2 will the negatives cancel out into positives?
The first two will cancel, then the third will turn the final answer to a negative.
-3 times -8 is +24 , +24 times -2 is -48.

Dividing Involving Zero;
5 / 5 = 1 , 0 / -5 = 0 , -5 / 0 = undefined , 0/0 = undefined
You see, if you do 0/5, it would be 0 because 0 x 5 = 0. Yet if you do 5/0 it would be undefined because
no matter what you try to multiply by 0 to get 5, you always get 0.

But why is it that 0 divided by 0 be undefined!? shouldn't it be 1? because if you ask yourself how many times
does 0 go into 0 would it be 1? Surely this is the basic rules of division that say "a number that goes into itself
will always be 1"? (but does this not apply for zero?)
Several people stated that dividing by 0 is undefined, which is correct. However, take n/n, where n is not 0.
It is always 1 and, thus, makes 0/0 seems like it should be 1.
On the other hand, take 0/n, where n is not 0. It is always 0 and, thus, makes 0/0 seems like it should be 0.
It can't be both 1 and 0, so it cannot be determined consistently: therefore the actual convention is: 'undefined' .

Differing Conventions (!) in computer programs!! (take as only one example!);
There exist differing conventions concerning the unary operator - (usually read "minus"). In written or printed
mathematics, the expression -3^2 is interpreted to mean -(3^2) = -9, but in some applications and programming
languages, notably BASIC programming language, the application Microsoft Office Excel and the programming
language 'bc', unary operators have a higher priority than binary operators, that is, the unary minus (negation) has
higher precedence than exponentiation, so in those languages -3^2 will be interpreted as (-3)^2 = 9
.
На самом деле это фича, так как мне пришлось писать целых уровень парсинга ради этого.

Re: Calc+

Posted: Tue Apr 22, 2014 8:45 pm
by Wildwest
Пример калькулятора, который дает другой результат

http://www.calculator888.ru/

-1^2=1

Re: Calc+

Posted: Tue Apr 22, 2014 8:51 pm
by e-andrew
Wildwest wrote:Пример калькулятора, который дает другой результат

http://www.calculator888.ru/

-1^2=1
Не забывай, что там не калькулятор выражений. Мало того, я больше доверяю гуглу). Стандартный калькулятор выражений на телефоне и на пк говорит, что -2^2=-4. Вообщем, спорный вопрос. Как написано в тексте в моём предыдущем посте, -2^2=-4 - математически правильно.

Re: Calc+

Posted: Wed Apr 23, 2014 4:09 pm
by popovpa
-2^2 = 4 (-2*-2 = 4) -2^2 = -4 математически не верно...квадратный корень из -4 не равен -2. Возможно вы имеете ввиду -1*(2)^2 тогда да -4...

Re: Calc+

Posted: Wed Apr 23, 2014 6:12 pm
by e-andrew
Calc+ v0.3β
  • Добавлена поддержка функций
  • Добавлены функции inc(n), dec(n), abs(n), sqr(n)

Re: Calc+

Posted: Wed Apr 23, 2014 6:15 pm
by SoUrcerer
А можно ещё добавить заметную кнопочку "?" с мануалом?

Re: Calc+

Posted: Wed Apr 23, 2014 6:23 pm
by buyerninety
From previous post above ;
" In written or printed mathematics, the expression -3 ^ 2 is interpreted to mean - (3 ^ 2) = -9 "

Above sentence actually comes directly from Google;
http://en.wikipedia.org/wiki/Order_of_o ... e_standard
and Google cites origin for the sentence as a mathematics textbook in the United States ;
'Elementary Algebra for College Students' .

====================
Wildwest correctly says " Тут могут быть проблемы с написанием формул.
Например можно написать -1^2 и иметь в виду (-1)^2=-1*-1=1, а не -(1^2) "

This was previously discussed briefly in CHAT (Sun Apr 20, 2014 2:51 pm);
chatlogs/chatlog2014-04-20.html and my suggestion was that;
" 'people MUST input the 'implied' terms {such as implied brackets} when inputting into calc'
(note implied=understood instinctively)
"

e-andrew has made the decision to code such that " -X ^ n == - (x ^ n) "
(I do not dissent from his coding decision. I agree correct decision.)

For Wildwest given scenario, I suggest that we should regard it, that it is the
responsibility of person inputting, to ensure they input according to generally
accepted conventions of mathematics. If a person mistakely inputs, (not
according to the convention of mathematics) - to that person falls the blame.
If they input -1^2 then they will get -1 . {because e-andrew code will regard as -(1^2) ,
this agrees with the convention of mathematics}.
{ popovpa@
Logically, it can also be said that -(1^2) , that should be understood as -(1 * 1) ,
instead of regarding as -1 * -1 . } :)

Wildwest gives example of another online calcuator which gives wrong answer.
I found this, http://easycalculation.com/basic-scient ... ulator.php in which it
will not even allow me to input -(1^2), {using x^y button !!} Therefore, I'm
a bit impressed because e-andrew program gives correct answer, (Wildwest and myself
found other some programs give answers wrong or do not even allow input!! :shock: )

Regarding; " А можно ещё добавить заметную кнопочку "?" с мануалом? "
мануалом does not need to be fancy affair, can be simple as list of set of
mathmatical rules that Calc+ follows, {unless SoUrcerer requires otherwise}
already e-andrew has written it so ;
-x^n == -(x^n)

Re: Calc+

Posted: Wed Apr 23, 2014 6:25 pm
by e-andrew
SoUrcerer wrote:А можно ещё добавить заметную кнопочку "?" с мануалом?
С мануалом чего? Калькулятора?) Ну вообще да, идея хорошая. Большинство функций будет вынесено в кнопки (куда эти кнопки ставить хз), но некоторые малонужные (вроде inc, dec, str) в кнопках не будут. Скорее всего, реализую с помощью docpack.

Re: Calc+

Posted: Wed Apr 23, 2014 6:29 pm
by e-andrew
buyerninety wrote: Wildwest gives example of another online calcuator which gives wrong answer.
I found this, http://easycalculation.com/basic-scient ... ulator.php in which it
will not even allow me to input -(1^2), {using x^y button !!} Therefore, I'm
a bit impressed because e-andrew program gives correct answer, (Wildwest and myself
found other some programs give answers wrong or do not even allow input!! :shock: )
These two calculators gives tгue answers, becouse they are not a calcualotors of expressions. They take two arguements and do operation above it.

Re: Calc+

Posted: Sat May 24, 2014 9:27 pm
by e-andrew
Временно понерфен интерфейс (нужно для будущих апдейтов). Теперь считается по нажатию на Enter. Добавлены две кнопки (клавиатура и помощь), но они пока что не работают.

Re: Calc+

Posted: Mon May 26, 2014 10:12 pm
by e-andrew
Calc+ v0.5
by e-andrew (совместно с Mister Nikto)
  • Полностью переработан интерфейс.
  • История расчётов. По клику на пункт списка истории ответ копируется в строку ввода. Если выражение не влезает, то оно обрезается и в конец добавляется "...".
  • Добавлен оператор | (модуль). Для тех, кто не помнит, |-6 + 1| = 5.
  • Улучшена клавиатура. Мало того, теперь она по умолчанию скрыта. Чтобы открыть её, нужно нажать на кнопку "Keyboard >" в заголовке.
  • Убран автоматический расчёт. Фича хорошая, но бесполезная.
  • Кнопка "Стереть" вынесена в поле ввода.
Запускать лучше всего из этого образа.