Skip to content
Commits on Source (64)
Overview of changes in gnome-calculator 44.beta
* Updated translations
* Improved factorization !141 (J. Sory)
* Number format selection documentation improvements #321 (Robert Roth)
* Made builtin function descriptions translatable #323 (Robert Roth)
* Fixed display showing 0 on startup #318 (Robert Roth)
* Improved button tooltips !132 (sunflowerskater)
* Added signed int support to programming mode !110 (Erik Wolf)
* i and e constants updated according to ISO 80000-2:2009 !137 (majjejjam)
* Help overlay updates !133 (Sabri Ünal)
* Added preferences shortcut !129 (Sabri Ünal)
* Destroy dialog after clicking cancel #310 (Jaycee Santos)
Overview of changes in gnome-calculator 43.0.1
* Fixed appdata versioning (Robert Roth)
......
......@@ -32,19 +32,24 @@
</description>
<screenshots>
<screenshot type="default">
<image>https://gitlab.gnome.org/GNOME/gnome-calculator/raw/HEAD/data/screenshots/basic-mode.png</image>
<caption>Basic Mode</caption>
<image>https://static.gnome.org/appdata/gnome-43/calculator/basic-mode.png</image>
</screenshot>
<screenshot>
<image>https://gitlab.gnome.org/GNOME/gnome-calculator/raw/HEAD/data/screenshots/advanced-mode.png</image>
<caption>Advanced Mode</caption>
<image>https://static.gnome.org/appdata/gnome-43/calculator/advanced-mode.png</image>
</screenshot>
<screenshot>
<image>https://gitlab.gnome.org/GNOME/gnome-calculator/raw/HEAD/data/screenshots/financial-mode.png</image>
<caption>Financial Mode</caption>
<image>https://static.gnome.org/appdata/gnome-43/calculator/financial-mode.png</image>
</screenshot>
<screenshot>
<image>https://gitlab.gnome.org/GNOME/gnome-calculator/raw/HEAD/data/screenshots/programming-mode.png</image>
<caption>Programming Mode</caption>
<image>https://static.gnome.org/appdata/gnome-43/calculator/programming-mode.png</image>
</screenshot>
<screenshot>
<image>https://gitlab.gnome.org/GNOME/gnome-calculator/raw/HEAD/data/screenshots/keyboard-mode.png</image>
<caption>Keyboard Mode</caption>
<image>https://static.gnome.org/appdata/gnome-43/calculator/keyboard-mode.png</image>
</screenshot>
</screenshots>
<update_contact>mcatanzaro_at_gnome.org</update_contact>
......@@ -71,6 +76,24 @@
<translation type="gettext">gnome-calculator</translation>
<content_rating type="oars-1.1" />
<releases>
<release version="44~beta" date="2023-02-11" type="development">
<description>
<p>Overview of changes in gnome-calculator 44.beta</p>
<ul>
<li>Updated translations</li>
<li>Improved factorization !141 (J. Sory)</li>
<li>Number format selection documentation improvements #321 (Robert Roth)</li>
<li>Made builtin function descriptions translatable #323 (Robert Roth)</li>
<li>Fixed display showing 0 on startup #318 (Robert Roth)</li>
<li>Improved button tooltips !132 (sunflowerskater)</li>
<li>Added signed int support to programming mode !110 (Erik Wolf)</li>
<li>i and e constants updated according to ISO 80000-2:2009 !137 (majjejjam)</li>
<li>Help overlay updates !133 (Sabri Ünal)</li>
<li>Added preferences shortcut !129 (Sabri Ünal)</li>
<li>Destroy dialog after clicking cancel #310 (Jaycee Santos)</li>
</ul>
</description>
</release>
<release version="43.0.1" date="2022-09-16" type="stable">
<description>
<p>Overview of changes in gnome-calculator 43.0.1</p>
......
gnome-calculator (1:44~beta-1ubuntu1) lunar; urgency=medium
* Merge with Debian, remaining change:
- Add ubuntu/search-provider-Cancel-operations-on-XUbuntuCancel.patch:
+ Use XUbuntuCancel with GNOME Shell search provider to stop
expensive processes that might lead to an unresponsive process
-- Jeremy Bicha <jbicha@ubuntu.com> Tue, 14 Feb 2023 15:30:19 -0500
gnome-calculator (1:44~beta-1) experimental; urgency=medium
* New upstream release
-- Jeremy Bicha <jbicha@ubuntu.com> Tue, 14 Feb 2023 15:26:27 -0500
gnome-calculator (1:43.0.1-2ubuntu1) lunar; urgency=medium
* Merge with Debian, remaining change:
......
......@@ -10,7 +10,7 @@
<p>
To change the format used to display results, press the menu button in the
top-right corner of the window and select <gui style="menuitem">Preferences</gui>.
top-right corner of the window and select the number format to use from the menu.
</p>
<table>
......@@ -32,6 +32,6 @@
</tr>
</table>
<p>
The number of decimal places, if trailing zeroes and if thousands separators are shown can also be configured.
The number of decimal places, if trailing zeroes and if thousands separators are shown can also be configured in <gui style="menuitem">Preferences</gui>.
</p>
</page>
......@@ -26,6 +26,7 @@ ru
sl
sv
te
tr
uk
zh_CN
zh_HK
......
......@@ -6,21 +6,22 @@
# Mario Blättermann <mario.blaettermann@gmail.com>, 2010, 2012, 2013, 2020.
# Tim Sabsch <tim@sabsch.com>, 2018, 2021.
# Philipp Kiemle <philipp.kiemle@gmail.com>, 2021.
# Jürgen Benvenuti <gastornis@posteo.org>, 2023.
#
#
msgid ""
msgstr ""
"Project-Id-Version: gcalctool master\n"
"POT-Creation-Date: 2021-08-12 20:23+0000\n"
"PO-Revision-Date: 2021-08-16 19:57+0200\n"
"Last-Translator: Philipp Kiemle <philipp.kiemle@gmail.com>\n"
"Language-Team: Deutsch <gnome-de@gnome.org>\n"
"POT-Creation-Date: 2022-07-08 07:39+0000\n"
"PO-Revision-Date: 2023-01-02 13:38+0100\n"
"Last-Translator: Jürgen Benvenuti <gastornis@posteo.org>\n"
"Language-Team: German <gnome-de@gnome.org>\n"
"Language: de\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.4.2\n"
"X-Generator: Poedit 3.1.1\n"
#. Put one translator per line, in the form NAME <EMAIL>, YEAR1, YEAR2
msgctxt "_"
......@@ -31,7 +32,8 @@ msgstr ""
"2008,2009,2010,2014,2015,2017,2021\n"
"Mario Blättermann <mario.blaettermann@gmail.com>, 2012, 2013, 2020\n"
"Jakob Kramer <jakob.kramer@gmx.de>, 2010\n"
"Tim Sabsch <tim@sabsch.com>, 2018"
"Tim Sabsch <tim@sabsch.com>, 2018\n"
"Jürgen Benvenuti <gastornis@posteo.org>, 2023"
#. (itstool) path: page/title
#: C/absolute.page:9
......@@ -467,7 +469,7 @@ msgid ""
"To solve, press the <gui>=</gui> button with your mouse or the <key>Enter</"
"key> key on your keyboard."
msgstr ""
"Um zu lösen, klicken Sie auf den <gui>=</gui>-Knopf oder drücken die "
"Um zu lösen, klicken Sie auf den <gui>=</gui>-Knopf oder drücken Sie die "
"<key>Eingabetaste</key>."
#. (itstool) path: page/p
......@@ -506,7 +508,7 @@ msgid ""
"To clear the display press the <gui>C</gui> button or <key>Escape</key>."
msgstr ""
"Um die Anzeige zu leeren, klicken Sie auf den Knopf <gui>C</gui> oder "
"drücken die <key>Esc</key>-Taste."
"drücken Sie die <key>Esc</key>-Taste."
#. (itstool) path: page/title
#: C/factorial.page:9
......@@ -735,8 +737,8 @@ msgid ""
"single variable</link> then write each argument separated by semicolon and "
"use parenthesis around the argument list."
msgstr ""
"Funktionen können verwendet werden, indem Sie die Funktion gefolgt von den "
"Funktionsargumenten eingeben. <app>Taschenrechner</app> unterstützt auch "
"Funktionen können verwendet werden, indem Sie die Funktion, gefolgt von den "
"Funktionsargumenten, eingeben. <app>Taschenrechner</app> unterstützt auch "
"benutzerdefinierte Funktionen. Sollte das Argument weder eine Zahl noch "
"<link xref=\"variable\">eine einzelne Variable</link> sein, so trennen Sie "
"jedes Argument durch ein Semikolon und setzen Sie die Liste der Argumente in "
......@@ -795,13 +797,14 @@ msgid ""
msgstr ""
"Klicken Sie auf f(x). Erfassen Sie den Namen der Funktion, wählen Sie die "
"Anzahl der Argumente und klicken Sie auf das Plus-Symbol daneben. Im "
"Taschenrechner geben Sie die den Ausdruck der Funktion ein und drücken die "
"Taschenrechner geben Sie den Ausdruck der Funktion ein und drücken Sie die "
"<key>Enter</key>-Taste."
#. (itstool) path: example/p
#: C/functions.page:43
msgid "Click on f(x). Choose the function and click on it."
msgstr "Klicken Sie auf f(x). Wählen Sie die Funktion und klicken auf diese."
msgstr ""
"Klicken Sie auf f(x). Wählen Sie die Funktion und klicken Sie auf diese."
#. (itstool) path: page/p
#: C/functions.page:47
......@@ -945,7 +948,7 @@ msgid ""
"previous calculations in the form of a scrollable list that can be clicked "
"and scrolled through using a mouse."
msgstr ""
"Die Chronikansicht beindet sich über dem Eingabefeld und listet die "
"Die Chronikansicht befindet sich über dem Eingabefeld und listet die "
"vorherigen Ergebnisse auf in Form einer durchsuchbaren Liste. Sie kann mit "
"einer Maus durchgeblättert werden."
......@@ -1330,7 +1333,7 @@ msgid ""
"are shown can also be configured."
msgstr ""
"Die Anzahl der Dezimalstellen bei angehängten Nullen und Tausender-"
"Trennzeichen können ebenfalls angepasst werden."
"Trennzeichen kann ebenfalls angepasst werden."
#. (itstool) path: page/title
#: C/percentage.page:9
......@@ -1350,7 +1353,7 @@ msgid ""
"the price of a $140 item with 15% tax (140 + (15÷100)×140)."
msgstr ""
"Bei Addition oder Subtraktion wird das Prozentsymbol zu einem Hundertstel "
"des Werts aufgelöst, zu dem der Term addiert oder Subtrahiert wird. Die "
"des Werts aufgelöst, zu dem der Term addiert oder subtrahiert wird. Die "
"folgende Gleichung berechnet den Preis eines Produktes im Wert von 140€ "
"zuzüglich 15% Steuern (140 + (15÷100)×140)."
......@@ -1677,9 +1680,9 @@ msgid ""
"characters."
msgstr ""
"Um einen Wert einer Variable zuzuweisen, verwenden Sie das Symbol »=« oder "
"wählen die zuzuweisende Variable mit dem <gui>x</gui>-Knopf im <link xref="
"\"mouse\">erweiterten Modus</link> aus. Der Name einer Variablen darf nur "
"Groß- und Kleinbuchstaben enthalten."
"wählen Sie die zuzuweisende Variable mit dem <gui>x</gui>-Knopf im <link "
"xref=\"mouse\">erweiterten Modus</link> aus. Der Name einer Variablen darf "
"nur Groß- und Kleinbuchstaben enthalten."
#. (itstool) path: example/p
#: C/variables.page:16
......
......@@ -9,20 +9,21 @@
# Alain Lojewski <allomervan@gmail.com>, 2014.
# Guillaume Bernard <associations@guillaume-bernard.fr>, 2015-2021.
# Sylvestris <sylvestris@tutanota.com>, 2020.
# Charles Monzat <charles.monzat@free.fr>, 2022.
#
msgid ""
msgstr ""
"Project-Id-Version: gnome-calculator documentation\n"
"POT-Creation-Date: 2021-03-25 23:18+0000\n"
"PO-Revision-Date: 2021-09-05 10:55+0200\n"
"Last-Translator: Guillaume Bernard <associations@guillaume-bernard.fr>\n"
"Language-Team: French <gnomefr@traduc.org>\n"
"POT-Creation-Date: 2022-04-07 15:57+0000\n"
"PO-Revision-Date: 2022-04-11 18:54+0200\n"
"Last-Translator: Charles Monzat <charles.monzat@free.fr>\n"
"Language-Team: GNOME French Team <gnomefr@traduc.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 2.4.2\n"
"X-Generator: Gtranslator 40.0\n"
#. Put one translator per line, in the form NAME <EMAIL>, YEAR1, YEAR2
msgctxt "_"
......@@ -1101,13 +1102,13 @@ msgstr ""
#: C/legal.xml:4
msgid "Creative Commons Attribution-Share Alike 3.0 Unported License"
msgstr ""
"Licence Creative Commons Paternité-Partage dans les conditions Identiques à "
"l’Initiale 3.0 non transposée"
"Licence Creative Commons Attribution - Partage dans les Mêmes Conditions 3.0 "
"non transposé."
#. (itstool) path: license/p
#: C/legal.xml:3
msgid "This work is licensed under a <_:link-1/>."
msgstr "Cette œuvre est sous licence <_:link-1/>."
msgstr "Cette œuvre est distribuée sous <_:link-1/>."
#. (itstool) path: license/p
#: C/legal.xml:6
......
This diff is collapsed.
This diff is collapsed.
......@@ -2,20 +2,21 @@
# Copyright (C) 2020 gnome-calculator's COPYRIGHT HOLDER
# This file is distributed under the same license as the gnome-calculator package.
#
# Yuri Chornoivan <yurchor@ukr.net>, 2020, 2021.
# Yuri Chornoivan <yurchor@ukr.net>, 2020, 2021, 2023.
msgid ""
msgstr ""
"Project-Id-Version: gnome-calculator master\n"
"POT-Creation-Date: 2021-03-25 23:18+0000\n"
"PO-Revision-Date: 2021-03-26 09:01+0200\n"
"POT-Creation-Date: 2023-02-10 11:36+0000\n"
"PO-Revision-Date: 2023-02-11 18:21+0200\n"
"Last-Translator: Yuri Chornoivan <yurchor@ukr.net>\n"
"Language-Team: Ukrainian <trans-uk@lists.fedoraproject.org>\n"
"Language: uk\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=4; plural=n==1 ? 3 : n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Lokalize 20.11.70\n"
"Plural-Forms: nplurals=4; plural=n==1 ? 3 : n%10==1 && n%100!=11 ? 0 : n"
"%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Lokalize 20.12.0\n"
#. Put one translator per line, in the form NAME <EMAIL>, YEAR1, YEAR2
msgctxt "_"
......@@ -262,7 +263,8 @@ msgstr "1010₂ in octal"
#. (itstool) path: note/p
#: C/conv-base.page:29
msgid "Number Base conversions must be performed using the keyboard."
msgstr "Перетворення системи числення слід виконувати за допомогою клавіатури."
msgstr ""
"Перетворення системи числення слід виконувати за допомогою клавіатури."
#. (itstool) path: page/title
#: C/conv-character.page:9
......@@ -949,21 +951,18 @@ msgstr ""
#. (itstool) path: info/title
#: C/index.page:7
#| msgid "<_:media-1/> Calculator Help"
msgctxt "link:trail"
msgid "Calculator Help"
msgstr "Довідка з «Калькулятора»"
#. (itstool) path: info/title
#: C/index.page:8
#| msgid "<_:media-1/> Calculator Help"
msgctxt "text"
msgid "Calculator Help"
msgstr "Довідка з «Калькулятора»"
#. (itstool) path: info/title
#: C/index.page:9
#| msgid "<_:media-1/> Calculator Help"
msgctxt "link"
msgid "Calculator Help"
msgstr "Довідка з «Калькулятора»"
......@@ -1245,14 +1244,18 @@ msgstr "Формат результату"
#. (itstool) path: page/p
#: C/number-display.page:11
#| msgid ""
#| "To change the format used to display results, press the menu button in "
#| "the top-right corner of the window and select <gui style=\"menuitem"
#| "\">Preferences</gui>."
msgid ""
"To change the format used to display results, press the menu button in the "
"top-right corner of the window and select <gui style=\"menuitem"
"\">Preferences</gui>."
"top-right corner of the window and select the number format to use from the "
"menu."
msgstr ""
"Щоб змінити формат, який буде використано для показу результатів, натисніть "
"кнопку меню у верхньому правому куті вікна і виберіть <gui style=\"menuitem"
"\">Параметри</gui>."
"кнопку меню у верхньому правому куті вікна і виберіть у меню формат чисел,"
" яким слід скористатися."
#. (itstool) path: td/p
#: C/number-display.page:18
......@@ -1306,12 +1309,17 @@ msgstr ""
#. (itstool) path: page/p
#: C/number-display.page:34
#| msgid ""
#| "The number of decimal places, if trailing zeroes and if thousands "
#| "separators are shown can also be configured."
msgid ""
"The number of decimal places, if trailing zeroes and if thousands separators "
"are shown can also be configured."
"are shown can also be configured in <gui style=\"menuitem\">Preferences</"
"gui>."
msgstr ""
"Також можна налаштувати кількість десяткових позицій, те, чи слід показувати "
"кінцеві нулі, і те, чи слід показувати роздільники тисяч."
"кінцеві нулі, і те, чи слід показувати роздільники тисяч, у <gui"
" style=\"menuitem\">Параметрах</gui>."
#. (itstool) path: page/title
#: C/percentage.page:9
......@@ -1741,7 +1749,8 @@ msgstr "rand"
#. (itstool) path: td/p
#: C/variables.page:57
msgid "Random value in the range [0,1] (changes on each read)"
msgstr "Випадкове число у діапазоні [0;1] (змінюється під час кожного читання)"
msgstr ""
"Випадкове число у діапазоні [0;1] (змінюється під час кожного читання)"
#~ msgid ""
#~ "The History View is located above the entry box and is designed to show "
......
......@@ -45,73 +45,73 @@ public class FunctionManager : Object
private void reload_builtin_functions ()
{
add (new BuiltInMathFunction ("log", "Logarithm"));
add (new BuiltInMathFunction ("log", _("Logarithm")));
add (new BuiltInMathFunction ("ln", "Natural logarithm"));
add (new BuiltInMathFunction ("ln", _("Natural logarithm")));
add (new BuiltInMathFunction ("sqrt", "Square root"));
add (new BuiltInMathFunction ("sqrt", _("Square root")));
add (new BuiltInMathFunction ("abs", "Absolute value"));
add (new BuiltInMathFunction ("abs", _("Absolute value")));
add (new BuiltInMathFunction ("sgn", "Signum"));
add (new BuiltInMathFunction ("sgn", _("Signum")));
add (new BuiltInMathFunction ("arg", "Argument"));
add (new BuiltInMathFunction ("arg", _("Argument")));
add (new BuiltInMathFunction ("conj", "Conjugate"));
add (new BuiltInMathFunction ("conj", _("Conjugate")));
add (new BuiltInMathFunction ("int", "Integer"));
add (new BuiltInMathFunction ("int", _("Integer")));
add (new BuiltInMathFunction ("frac", "Fraction"));
add (new BuiltInMathFunction ("frac", _("Fraction")));
add (new BuiltInMathFunction ("floor", "Floor"));
add (new BuiltInMathFunction ("floor", _("Floor")));
add (new BuiltInMathFunction ("ceil", "Ceiling"));
add (new BuiltInMathFunction ("ceil", _("Ceiling")));
add (new BuiltInMathFunction ("round", "Round"));
add (new BuiltInMathFunction ("round", _("Round")));
add (new BuiltInMathFunction ("re", "Real"));
add (new BuiltInMathFunction ("re", _("Real")));
add (new BuiltInMathFunction ("im", "Imaginary"));
add (new BuiltInMathFunction ("im", _("Imaginary")));
add (new BuiltInMathFunction ("sin", "Sine"));
add (new BuiltInMathFunction ("sin", _("Sine")));
add (new BuiltInMathFunction ("cos", "Cosine"));
add (new BuiltInMathFunction ("cos", _("Cosine")));
add (new BuiltInMathFunction ("tan", "Tangent"));
add (new BuiltInMathFunction ("tan", _("Tangent")));
add (new BuiltInMathFunction ("asin", "Arc sine"));
add (new BuiltInMathFunction ("asin", _("Arc sine")));
add (new BuiltInMathFunction ("acos", "Arc cosine"));
add (new BuiltInMathFunction ("acos", _("Arc cosine")));
add (new BuiltInMathFunction ("atan", "Arc tangent"));
add (new BuiltInMathFunction ("atan", _("Arc tangent")));
add (new BuiltInMathFunction ("sin⁻¹", "Inverse sine"));
add (new BuiltInMathFunction ("sin⁻¹", _("Inverse sine")));
add (new BuiltInMathFunction ("cos⁻¹", "Inverse cosine"));
add (new BuiltInMathFunction ("cos⁻¹", _("Inverse cosine")));
add (new BuiltInMathFunction ("tan⁻¹", "Inverse tangent"));
add (new BuiltInMathFunction ("tan⁻¹", _("Inverse tangent")));
add (new BuiltInMathFunction ("sinh", "Hyperbolic sine"));
add (new BuiltInMathFunction ("sinh", _("Hyperbolic sine")));
add (new BuiltInMathFunction ("cosh", "Hyperbolic cosine"));
add (new BuiltInMathFunction ("cosh", _("Hyperbolic cosine")));
add (new BuiltInMathFunction ("tanh", "Hyperbolic tangent"));
add (new BuiltInMathFunction ("tanh", _("Hyperbolic tangent")));
add (new BuiltInMathFunction ("sinh⁻¹", "Hyperbolic arcsine"));
add (new BuiltInMathFunction ("sinh⁻¹", _("Hyperbolic arcsine")));
add (new BuiltInMathFunction ("cosh⁻¹", "Hyperbolic arccosine"));
add (new BuiltInMathFunction ("cosh⁻¹", _("Hyperbolic arccosine")));
add (new BuiltInMathFunction ("tanh⁻¹", "Hyperbolic arctangent"));
add (new BuiltInMathFunction ("tanh⁻¹", _("Hyperbolic arctangent")));
add (new BuiltInMathFunction ("asinh", "Inverse hyperbolic sine"));
add (new BuiltInMathFunction ("asinh", _("Inverse hyperbolic sine")));
add (new BuiltInMathFunction ("acosh", "Inverse hyperbolic cosine"));
add (new BuiltInMathFunction ("acosh", _("Inverse hyperbolic cosine")));
add (new BuiltInMathFunction ("atanh", "Inverse hyperbolic tangent"));
add (new BuiltInMathFunction ("atanh", _("Inverse hyperbolic tangent")));
add (new BuiltInMathFunction ("ones", "One's complement"));
add (new BuiltInMathFunction ("ones", _("One's complement")));
add (new BuiltInMathFunction ("twos", "Two's complement"));
add (new BuiltInMathFunction ("twos", _("Two's complement")));
}
private void reload_custom_functions ()
......
......@@ -56,9 +56,44 @@ public class MathEquation : GtkSource.Buffer
if (_word_size == value)
return;
_word_size = value;
if (status != "")
apply_word_size(_word_size);
}
}
private void apply_word_size(uint size)
{
var x = number;
uint64 bits = 0;
var min = new Number.integer (int64.MIN);
var max = new Number.unsigned_integer (uint64.MAX);
if (x == null || x.compare (max) > 0 || x.compare (min) < 0)
{
/* Message displayed when cannot toggle bit in display */
status = _("Displayed value not an integer");
return;
}
else if (x.is_negative ())
bits = x.to_integer ();
else
bits = x.to_unsigned_integer ();
var signed_bit = (bits >> (word_size - 1)) & 0x1;
if (x.is_negative () && signed_bit == 0x1) {
/* When the current number is negative and the signed bit is set according to two's complement
representation the resulting integer shall keep the sign. */
bits &= uint64.MAX >> (64 - size);
bits |= uint64.MAX << (size);
x = new Number.integer ((int64)bits);
} else {
bits &= uint64.MAX >> (64 - size);
x = new Number.unsigned_integer (bits);
}
// FIXME: Only do this if in ans format, otherwise set text in same format as previous number
set_number (x);
}
private string _source_currency;
public string source_currency
{
......@@ -189,7 +224,6 @@ public class MathEquation : GtkSource.Buffer
state = new MathEquationState ();
state.status = "";
word_size = 32;
_angle_units = AngleUnit.DEGREES;
// FIXME: Pick based on locale
source_currency = "";
......@@ -204,6 +238,8 @@ public class MathEquation : GtkSource.Buffer
ans_tag = create_tag (null, "weight", Pango.Weight.BOLD, null);
word_size = 32;
var style_manager = Adw.StyleManager.get_default ();
var style_scheme_manager = GtkSource.StyleSchemeManager.get_default ();
light_scheme = style_scheme_manager.get_scheme ("Classic");
......@@ -1366,17 +1402,25 @@ public class MathEquation : GtkSource.Buffer
public void toggle_bit (uint bit)
{
var x = number;
var min = new Number.integer (int64.MIN);
var max = new Number.unsigned_integer (uint64.MAX);
if (x == null || x.is_negative () || x.compare (max) > 0)
uint64 bits = 0;
if (x == null || x.compare (max) > 0 || x.compare (min) < 0)
{
/* Message displayed when cannot toggle bit in display */
status = _("Displayed value not an integer");
return;
}
else if (x.is_negative ())
bits = x.to_integer ();
else
bits = x.to_unsigned_integer ();
var bits = x.to_unsigned_integer ();
bits ^= (1LL << (63 - bit));
x = new Number.unsigned_integer (bits);
if (x.is_negative ())
x = new Number.integer ((int64)bits);
else
x = new Number.unsigned_integer (bits);
// FIXME: Only do this if in ans format, otherwise set text in same format as previous number
set_number (x, false);
......
......@@ -895,6 +895,86 @@ public class Number : GLib.Object
return ones_complement (wordlen).add (new Number.integer (1));
}
/* In: An p := p \in 2Z+1; An b := gcd(b,p) = 1
Out: A boolean showing that p is probably prime */
private bool is_sprp (Number p, int64 b)
{
var unit = new Number.integer(1);
var pminus = p.subtract(unit);
var d = pminus;
var two = new Number.integer(2);
uint64 twofactor = 0;
// Strip out factors of two
while (true)
{
var tmp = d.divide (two);
if (tmp.is_integer ())
{
d = tmp;
twofactor = twofactor + 1;
}
else
break;
}
var x = new Number.integer(b).modular_exponentiation(d,p);
if ((x.equals(unit)) || (x.equals(pminus))){
return true;
}
for (var i = 1; i < twofactor; i++)
{
x = x.multiply (x);
x = x.modulus_divide(p);
if (x.equals(pminus))
{
return true;
}
}
return false;
}
/* In : An x := x \in 2Z+1 and gcd(x,[2,..,2ln(2)**2])=1
Out: A boolean correctly evaluating x as composite or prime assuming the GRH
Even if the GRH is false, the probability of number-theoretic error is far lower than
machine error */
private bool is_prime(Number x)
{
const int64 BASES[13] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,41};
var sup = x.ln().to_integer() + 1;
/* J.Sorenson & J.Webster's optimization */
if (sup < 56)
{
for (var i = 0; i < 13; i++)
{
if (!is_sprp(x,BASES[i])){
return false;
}
}
return true;
}
else
{
sup = sup*sup*2;
for (var i = 0; i < sup; i++)
{
if (!is_sprp(x,i))
{
return false;
}
}
return true;
}
}
/* Returns a list of all prime factors in x as Numbers */
public List<Number?> factorize ()
{
......@@ -913,13 +993,18 @@ public class Number : GLib.Object
factors.append (this);
return factors;
}
if (value.compare(new Number.integer(0xFFFFFFFF)) > 0)
{
if (is_prime(value))
{
factors.append (value);
return factors;
}
}
// if value < 2^64-1, call for factorize_uint64 function which deals in integers
uint64 num = 1;
num = num << 63;
num += (num - 1);
var int_max = new Number.unsigned_integer (num);
var int_max = new Number.unsigned_integer (0xFFFFFFFFFFFFFFFF);
if (value.compare (int_max) <= 0)
{
......@@ -969,6 +1054,7 @@ public class Number : GLib.Object
return factors;
}
public List<Number?> factorize_uint64 (uint64 n)
{
var factors = new List<Number?> ();
......
project('gnome-calculator', ['c', 'vala'],
version: '43.0.1',
version: '44.beta',
meson_version: '>= 0.57.0',
license: 'GPLv3+',
)
......
This diff is collapsed.