{"id":23041409,"url":"https://github.com/giocip/macos_num7","last_synced_at":"2026-04-30T15:33:14.188Z","repository":{"id":267938539,"uuid":"902820786","full_name":"giocip/MACOS_num7","owner":"giocip","description":"num7 ISO C++14 Standard 64-BIT LIBRARY, ARBITRARY-PRECISION GENERAL PURPOSE ARITHMETIC-LOGIC DECIMAL CLASS FOR MACOS SEQUOIA 15","archived":false,"fork":false,"pushed_at":"2025-04-24T17:47:08.000Z","size":1586,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-30T15:33:13.699Z","etag":null,"topics":["arbitrary","arithmetic","chatgpt","ieee754","mac","macos","math","precision"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giocip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["giocip"]}},"created_at":"2024-12-13T10:36:39.000Z","updated_at":"2025-04-25T09:56:56.000Z","dependencies_parsed_at":"2025-02-08T14:45:26.489Z","dependency_job_id":"41f9d6be-703c-452b-9e42-95b6bdcf3b04","html_url":"https://github.com/giocip/MACOS_num7","commit_stats":null,"previous_names":["giocip/macos_num7"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/giocip/MACOS_num7","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giocip%2FMACOS_num7","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giocip%2FMACOS_num7/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giocip%2FMACOS_num7/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giocip%2FMACOS_num7/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giocip","download_url":"https://codeload.github.com/giocip/MACOS_num7/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giocip%2FMACOS_num7/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32469344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arbitrary","arithmetic","chatgpt","ieee754","mac","macos","math","precision"],"created_at":"2024-12-15T19:33:36.917Z","updated_at":"2026-04-30T15:33:14.172Z","avatar_url":"https://github.com/giocip.png","language":"C++","funding_links":["https://github.com/sponsors/giocip"],"categories":[],"sub_categories":[],"readme":"# num7 - C++ ARBITRARY PRECISION ARITHMETIC-LOGIC DECIMAL LIBRARY FOR MACOS SEQUOIA 15.1\n## _DESCRIPTION AND DOC_\n\n- _**`num7.h`**_ is a C++ high-level (python3 style), lightweight, floating-point computing header file for ARBITRARY PRECISION DECIMAL ARITHMETIC.\n\nEasy to use like school math and WITHOUT IEEE754 ISSUES AND NUMBER COMPARING FAILURES, it can be deployed  \nfor educational school, web e-commerce developing, accounting apps and general math programs included financial ones and AI compliance.  \n\n\n---\n\n## Installation C++ num7.h and num7.cpp header files\n\n### Create a directory on your MACOS system and\n\n- With your favourite editor create num7.h and num7.cpp file and copy it along with your c++ app.cpp file in that same folder\n\n\n- Ok!\n\n---\n\n## HOW TO USE (integer numeric strings (ex. \"2.0\") MUST BE SUFFIXED WITH .0): \n--- CALCULATOR MODE ---   \n\n\t#include \"num7.h\"\n\tusing namespace num7;\n\n\tint main() {\n\n\t\t/* ADDITION           */ add(\"2.5\", \"3.6\").print(\" = 2.5 + 3.6 (ADDITION)\\n\"); //6.1                 \n\t\t/* SUBTRACTION        */ sub(\"2.5\", \"3.6\").print(\" = 2.5 - 3.6 (SUBTRACTION)\\n\"); //-1.1               \n\t\t/* MULTIPLICATION     */ mul(\"2.5\", \"3.6\").print(\" = 2.5 * 3.6 (MULTIPLICATION)\\n\"); //9.0                 \n\t\t/* DIVISION           */ div(\"2.5\", \"3.6\").print(\" = 2.5 / 3.6 (DIVISION)\\n\"); \t    //0.6944444444444444444444444444444444444444\n\t\t/* DIVISION REMAINDER */ mod(\"11.0\", \"8.0\").print(\" = 11 % 8 (DIVISION REMAINDER)\\n\"); //3.0                 \n\t\t/* INV                */ inv(\"3.0\").print(\" = 1 / 3 (INV)\\n\");  //0.33333333333333333333333333333333                \n\t\t/* x2                 */ x2(\"3.0\").print(\" = 3 ^ 2 (x2)\\n\");   //9.0\n\t\t/* x3                 */ x3(\"3.0\").print(\" = 3 ^ 3 (x3)\\n\");  //27.0\n\t\t/* POWER              */ xy(\"3.14\", \"8.0\").print(\" = 3.14 ^ 8 (POWER)\\n\");  //9450.1169810786918656\n\t\t/* POWER OF TEN       */ _10y(6).print(\" = 10^6 (TEN POWER)\\n\");           //1000000.0\n\t\t/* POWER OF TWO       */ _2y(5).print(\" = 2^5 (TWO POWER)\\n\");            //32.0\n\t\t/* POWER OF e         */ _ey(5).round(29).print(\" = e^5 (e POWER)\\n\");   //148.41315910257660342111558004056\n\t\t/* FACTORIAL          */ NUM P(fact(5)); P.print(\" = 5! (FACTORIAL)\\n\");//120\n\t\t/* BINARY             */ NUM n1(\"257.0\"); char* ram1 = n1.to_bin(1); print(ram1, \" = 257 (BINARY)     \\n\"); free(ram1); //100000001 = 257 (BINARY)\n\t\t/* HEXADECIMAL        */ NUM n2(\"257.0\"); char* ram2 = n2.to_bin(0); print(ram2, \" = 257 (HEXADECIMAL)\\n\"); free(ram2);//101 = 257 (HEXADECIMAL)\n\t\t/* SQUARE ROOT        */ sqr(\"2.0\").print(\" (SQUARE ROOT OF 2)\\n\"); \t   \t\t                //1.414213562         \n\t\t/* ROUND 2 DIGITS     */ round(sqr(\"2.0\")).print(\" = SQUARE ROOT OF 2 (ROUND 2 DIGITS)\\n\");            //1.41  \n\t\t/* ROUND 4 DIGITS     */ round(pi(), 4).print(\" =~ 3.141592654 (ROUND 4 DIGITS)\\n\"); \t                //3.1416\n\t\t/* ROUND BANKING      */ round_bank(pi(), 7).print(\" =~ 3.141592654 (ROUND BANKING 7 DIGITS)\\n\");    //3.1415926\n\t\t/* ABS                */ Abs(\"-5.25\").print(\" (ABSOLUTE VALUE OF -5.25)\\n\"); \t\t                    //5.25 \n\t\t/* EXP                */ NUM n3(\"314.0e-2\"); n3.print(\" = 314.0e-2 (EXP)\\n\");                      //3.14 = 314.0e-2 (EXP)\n\t\t/* SCIENTIFIC         */ NUM n4(\"314.0e-2\"); into_exp(n4).print(\" = 3.14e0 (SCI)\\n\");             //3.14 = 3.14e0 (SCI)\n\t\t/* pi                 */ pi().print(\" (pi)\\n\"); \t\t\t\t\t\t  //3.1415926535897932384626433832795\n\t\t/* e                  */ e().print(\" (e)\\n\");  \t\t\t\t\t\t\t //2.7182818284590452353602874713527\n\t\t/* 10 TIME VALUE      */ _10x(\"5.25\").print(\" (10 TIME VALUE OF 5.25)\\n\");                      //52.5\n\t\t/* 100 TIME VALUE     */ _100x(\"5.25\").print(\" (100 TIME VALUE OF 5.25)\\n\");                   //525.0\n\t\t/* 1000 TIME VALUE    */ _1000x(\"5.25\").print(\" (1000 TIME VALUE OF 5.25)\\n\");                //5250.0\n\t\t/* DIVIDE FOR 10      */ _10div(\"5.25\").print(\" (DIVISION FOR TEN OF 5.25)\\n\");              //0.525\n\t\t/* DIVIDE FOR 100     */ _100div(\"5.25\").print(\" (DIVISION FOR HUNDRED OF 5.25)\\n\");        //0.0525\n\t\t/* DIVIDE FOR 1000    */ _1000div(\"5.25\").print(\" (DIVISION FOR THOUSAND OF 5.25)\\n\");     //0.00525\n\t\t/* PERCENTAGE         */ pct(\"3.725\", \"150.00\").round(2).print(\" = 3.725% OF 150 (PERCENTAGE)\\n\");        //5.59\n\t\t/* PERTHOUSAND        */ pth(\"2.00\", \"20_000.00\").round(2).print(\" = 2PTH OF 20000 (PERTHOUSAND)\\n\");    //40.0\n\t\t/* SPIN-OFF           */ spinoff(\"22.00\", \"1_299.00\").round(2).print(\" = (-22%) 1299 (SPIN-OFF)\\n\"); \t  //1064.75\n\t\t/* SPIN-ON            */ spinon(\"22.00\", \"1_064.75\").round(2).print(\" = +22% OF 1064.75 (SPIN-ON)\\n\"); //1299.0\n\t\tprint(\"----------------------\\n\"); \t\t\t\t\t\t\t\t      //---------------------- \n\t\t#define ELEMENTS 5\n\t\tint elements = 5; NUM cart[ELEMENTS]; //19.31999 19.32 18.37 -15.13 -15.12 =\u003e ELEMENTS\n\t\tcart[0] = \"19.31999\"; cart[1] = \"19.32\"; cart[2] = \"18.37\"; cart[3] = \"-15.13\"; cart[4] = \"-15.12\"; \n\t\tfor (elements = 0; elements \u003c 5; elements++) print(cart[elements], \" \"); print(\"=\u003e ELEMENTS\\n\");   //19.31999 19.32 18.37 -15.13 -15.12 \n\t\t/* SUM   */ sum(cart, elements).print(\" =\u003e SUM\\n\");            //26.75999 \n\t\t/* MEAN  */ mean(cart, elements).round().print(\" =\u003e MEAN\\n\"); //5.35\n\t\t/* MIN   */ min(cart, elements).print(\" =\u003e MIN\\n\");          //-15.13 \n\t\t/* MAX   */ max(cart, elements).print(\" =\u003e MAX\\n\");         //19.32 \n\t\t/*MIN MAX*/ NUM* result = minmax(cart, elements);          //\n\t\tresult[0].print(\" =\u003e MIN, \"); \t                          //-15.13 =\u003e MIN and \n\t\tresult[1].print(\" =\u003e MAX\\n\");                            //19.32 =\u003e MAX \n\t\t/* FORMAT  */ NUM a(\"-3_000_000.0\"); char* ram4 = format(a); print(ram4); print(\" =\u003e FORMATTING\\n\"); free(ram4); //-3,000,000.00 =\u003e FORMATTING\n\t\tprint(\"----------------------\\n\");  //---------------------- \n\t\n\t\treturn 0;\n\t}\n \n## CODING:  \n\n(=) assignment:  \n\n\tNUM a(\"3.0\"), b(\"5.0\"), c(\"0.0\"); //DECLARATION AND INITIALIZATION\n\tprint(\"a = \"); print(a, \"  b = \"); print(b, \"  c = \"); print(c, \"\\n\");//a = 3.0 b = 5.0 c = 0.0  \n\n(+) adding:  \n\n\tNUM R = a + b + c;                 //DECLARATION AND INITIALIZATION\n\tprint(\"R = \"); print(R, \"\\n\");    //R = 8.0  \n\ta = \"0.1\"; b = \"0.2\"; c = \"0.0\"; //INITIALIZATION\n\tR = a + b + c;\n\tprint(\"R = \"); print(R, \"\\n\"); //R = 0.3  \n\n(-) subtracting:  \n\n\ta = \"0.1\"; b = \"0.2\"; c = \"0.3\";          //INITIALIZATION  \n\tR = a + b - c;                           //INITIALIZATION \n\tprint(\"R = \"); print(R, \"\\n\");          //R = 0.0 \n\ta = \"-3.99\"; b = \"-5.20\"; c = \"+3.01\"; //INITIALIZATION \n\tR = a - b - c; \t\t\t                  //INITIALIZATION \n\tprint(\"R = \"); print(R, \"\\n\");       //R = -1.8 \n\n(*) multiplying:  \n\n\ta = \"-3.99\"; b = \"-5.20\"; c = \"+3.01\"; //INITIALIZATION\n\tR = a * b * c;                        //INITIALIZATION \n\tprint(\"R = \"); print(R, \"\\n\");       //R = 62.45148\n\n(/) dividing:  \n\n\ta = \"3.0\"; b = \"5.7\"; \t\t        //INITIALIZATION\n\tR = a / b; \t\t\t                 //INITIALIZATION\n\tprint(\"R = \"); print(R, \"\\n\");  //R = 0.52631578947368421052631578947368\n\tprint(\"R = \"); print(div(a, b).round(), \"\\n\"); //R = 0.53\n\n(% operator) integer division and floating-point remainder:  \n\n\ta = 2564; b = 17; \t\t           //INITIALIZATION \n\tNUM quotient((a / b).trunk(0)); //DECLARATION AND INITIALIZATION \n\tNUM remainder(a % b); \t       //DECLARATION AND INITIALIZATION \n\tprint(\"quotient = \");  quotient.print(\"\\n\");  \t       //quotient = 150.0 \n\tprint(\"INTEGER remainder = \"); remainder.print(\"\\n\"); //INTEGER remainder = 14.0 \n\ta = \"3.141592654\"; b = 2;  \t\t\t                     //INITIALIZATION\n\tquotient = (a / b).trunk(0); remainder = a % b; \n\tprint(\"quotient = \");  quotient.print(\"\\n\");       //quotient = 1.0 \n\tprint(\"FLOATING-POINT Remainder = \"); remainder.print(\"\\n\");//FLOATING-POINT Remainder = 1.141592654 \n\n(sqrt) square root function:  \n\n\tNUM a(\"123_456_789.1234567891\");   //DECLARATION AND INITIALIZATION \n\tNUM root = a.sqrt(); \t            //DECLARATION AND INITIALIZATION \n\tprint(\"root = \", root, \"\\n\");\t   //root = 11111.111066\n\n(^) power operator and pow function:  \n\n\tNUM a(\"3.14\"), b(2);\t\t\t               //DECLARATION AND INITIALIZATION \n\tNUM power = a.pow(9); \t\t\t            //DECLARATION AND INITIALIZATION \n\tprint(\"power = \", power, \"\\n\");        //power = 29673.367320587092457984 \n\tpower = (b ^ 32); \t\t                //INITIALIZATION (power needs priority)\n\tprint(\"power = \", power, \"\\n\");      //power = 4294967296.0 \n\tprint(\"power = \", pow(a, b), \"\\n\"); //power = 9.8596 \n\nlogic (\u003c, \u003c=, \u003e, \u003e=, !=, ==) and relational operators (\u0026\u0026, ||, !).  \n\n(is ...):  \n\n\tNUM a(\"3.0\"), b(\"-5.0\"), c(\"1.53\"); //DECLARATION AND INITIALIZATION \n\tprint(a.is_positive(), \"\\n\");      //1 (true) \n\tprint(!a.is_zero(), \"\\n\");        //1 (true) \n\tprint(c.is_negative(), \"\\n\");    //0 (false) \n\tprint(b.is_negative(), \"\\n\");   //1 (true) \n\n(\u003c \u003c= \u003e \u003e= != ==): \n\n\tNUM a(\"0.0\"), b(\"0.1\"), c(\"-0.2\");                               //DECLARATION AND INITIALIZATION \n\tprint(a \u003c b, \" \"); print(a \u003c c, \" \"); print(b \u003c c, \"\\n\");       //1 0 0 (True  False False) \n\tprint(a \u003c= b, \" \"); print(a \u003c= c, \" \"); print(b \u003c= c, \"\\n\");   //1 0 0 (True  False False) \n\tprint(a \u003e b, \" \"); print(a \u003e c, \" \"); print(b \u003e c, \"\\n\");     //0 1 1 (False True  True)\n\tprint(a \u003e= a, \" \"); print(a \u003e= c, \" \"); print(b \u003e= c, \"\\n\"); //1 1 1 (True  True  True)\n\tprint(c == -2 * b, \" \"); print(a == c + 2 * b, \" \"); print(a != a + b + c, \"\\n\"); //1 1 1 (True  True  True)\n\tprint(a \u0026\u0026 b, \" \"); print(a || b, \" \"); print(!a, \"\\n\");   //0 1 1 (False  True True) \n\n(+ - unary operators):\n  \n\tNUM a, b;                  //DECLARATION \n\ta = \"-10.0\", b = \"+10.1\"; //INITIALIZATION  \n\tchar* p = a.format(); \n\tprint(\"a = \", p); free(p);              \n\tp = b.format(2, ',', true); //a = -10.00  b = +10.10 \n\tprint(\"  b = \", p, \"\\n\");  free(p); \n\nOn a given NUM variable the following arithmetic methods are available.\n\nvariable arithmetic:\n\n\tNUM a(\"10.25\"); \t\t            //DECLARATION AND INITIALIZATION\n\tprint(a, \"\\n\"); \t\t           //10.25\n\tprint(a.inc(1), \"\\n\"); \t\t    //11.25\n\tprint(a.dec(2), \"\\n\");\t\t   //9.25\n\tprint(a.dec(\"4.25\"), \"\\n\");\t//5.0\n\tprint(a, \"\\n\");\t\t\t //5.0\n\tprint(a = a.mul(\"5.01\"), \"\\n\"); //25.05\n\tprint(a, \"\\n\");\t\t             //25.05\n\tprint(a.clear(), \"\\n\");\t      //0.0\n\tprint(\"----------------------\\n\"); //----------------------\n\t\n\tNUM price(\"59.99\"), rate(\"22.00\");                    //DECLARATION AND INITIALIZATION\n\tprint(price, \"\\n\");                                  //59.99\n\tNUM price_industrial = price.spinoff(rate).round(); //DECLARATION AND INITIALIZATION\n\tprint(price_industrial, \"\\n\");                     //49.17\n\tprice = price_industrial.spinon(rate).round();    //INITIALIZATION\n\tprint(price, \" final price\\n\");                  //59.99 final price\n\tchar *p = (price - price.pct(\"17.49\").round()) .format();\n\tprint(p, \" discounted price\\n\"); free(p);      //49.50 discounted price\n\nEVEN ODD numbering methods:\n\n\tNUM a(6), b(3), c(\"3.14\"); //DECLARATION AND INITIALIZATION\n\tprint(a, \" INTEGER =\u003e \"); print(a.is_integer(), \"  EVEN =\u003e \"); print(a.is_even(), \"\\n\"); //6.0 INTEGER =\u003e 1 (true)  EVEN =\u003e 1 (true)\n\tprint(b, \" INTEGER =\u003e \"); print(a.is_integer(), \"  ODD =\u003e \"); print(b.is_odd(), \"\\n\"); //3.0 INTEGER =\u003e 1 (true)  ODD  =\u003e 1 (true)\n\tprint(c, \" FLOAT =\u003e \"); print(c.is_floating(), \"\\n\");\t\t\t\t                         //3.14 FLOAT  =\u003e 1 (true)\n\n# Advanced logic programming snippets:\n\n\tdouble A = -0.3; //double question //DECLARATION AND INITIALIZATION \n\tA += 0.1; A += 0.1; A += 0.1; \n\tif (A == 0.0) print(\"double, SUCCESS\"); \n\telse printf(\"double, FAILURE because %.6f is not equal 0.0\\n\", A); //double issue \n\tprint(\"----------------------\\n\"); \n\t\n\tNUM a(\"-0.3\"); //NUM question //DECLARATION AND INITIALIZATION \n\ta += \"0.1\"; a += \"0.1\"; a += \"0.1\"; \n\tif (a == \"0.0\") print(\"NUM, SUCCESS\", \"\\n\"); //NUM solved \n\telse print(\"NUM, FAILURE because \", a, \" is not equal 0.0\\n\"); \n\tprint(\"----------------------\\n\"); \n\t\n\t/* VIDEO OUTPUT: \n\t\tdouble, FAILURE because 0.000000 is not equal 0.0\n\t\t----------------------\n\t\tNUM, SUCCESS\n\t\t---------------------- */\n\nLOOP EXAMPLE:\n\n\tfor (NUM i(\"-1.0\"); i != (i64)0; i += \"0.1\") //-1.0 -0.9 -0.8 -0.7 -0.6 -0.5 -0.4 -0.3 -0.2 -0.1 \n\t\tprint(i, \" \"); \n\tprint(\"\\n----------------------\\n\"); \n\t\n\tNUM i(0); //DECLARATION AND INITIALIZATION \n\twhile (i \u003c \"1.0\") { \n\t\ti.inc(\"0.1\"); //i += NUM(\"0.1\") \n\t\tif (i \u003c= \"0.5\") continue; \n\t\tprint(i, \" \"); //0.6 0.7 0.8 0.9 1.0 \n\t} \n\tprint(\"\\n----------------------\\n\"); \n\n\twhile (i) { \n\t\ti.dec(\"0.1\"); //i -= NUM(\"0.1\") \n\t\tif (i \u003e= \"0.5\") continue; \n\t\tprint(i, \" \"); //0.4 0.3 0.2 0.1 0.0 \n\t} \n\tprint(\"\\n----------------------\\n\"); \n\nROUNDING AND ACCOUNTING:\n\n\tNUM p(\"11.19\"), discountRate(\"7.00\");       //DECLARATION AND INITIALIZATION - PRICE -Toslink cable for soundbar  \n\tprint(\"price=\", p); \n\tNUM d = round(p.pct(discountRate));       //DISCOUNT \n\tNUM pd = round(p - d);                   //PRICE DISCOUNTED 7%  \n\tNUM temp = pd; \n\tNUM p_noTAX = round(temp.spinoff(22)); //ITEM COST WITHOUT TAX 22%  \n\tNUM TAX = round(pd - p_noTAX);        //TAX 22% \n\tprint(\" PAYED=\", pd, \" discount=\"); print(d, \" COST=\"); print(p_noTAX, \" TAX=\"); print(TAX, \"\\n\"); \n\t//price=11.19 PAYED=10.41 discount=0.78 COST=8.53 TAX=1.88 \n\t\nOUTPUT LOCALIZATION, FORMATTING AND SQUARENESS:\n\n\tNUM amount (\"1_000_000.9\"); //DECLARATION AND INITIALIZATION\n\tint SIGN = true;\n\tint decs = 2;\n\tchar* p = amount.format(decs, ',', SIGN);\n\tprint(\"US localization =\u003e \", p, \"\\n\"); free(p); //US localization =\u003e +1,000,000.90\n\tp = amount.format(decs, '.', SIGN);\n\tprint(\"EU localization =\u003e \", p, \"\\n\"); free(p); //EU localization =\u003e +1.000.000,90\n    \n# Saving calculator: \n\t\n\t#include \"num7.h\"\n\tusing namespace num7;\n\t\n\tvoid asset() {\n\t\tNUM DEPOSIT(\"10_000.00\"), ANNUAL_CONTRIBUTION(\"1_000.00\"), RATE(\"7.25\"), YEARS(10), ANNUALS[10][4],\n\t\t\tSQUARENESS_1, SQUARENESS_2, SQUARENESS_3;\n\t\tfor (int i = 0; i \u003c YEARS; i++) {\n\t\t\tANNUALS[i][0] = i + 1;   //year \n\t\t\tANNUALS[i][1] = DEPOSIT; //deposit \n\t\t\tANNUALS[i][2] = ((DEPOSIT * RATE) / 100).round();\n\t\t\tANNUALS[i][3] = ANNUALS[i][1] + ANNUALS[i][2] + ANNUAL_CONTRIBUTION; DEPOSIT = ANNUALS[i][3];\n\t\t}\n\t\tint width = 12;\n\t\tfor (int i = 0; i \u003c YEARS; i++) {\n\t\t\tprint(ANNUALS[i][0].to_i32(), \"\\t\");\n\t\t\tchar* p = ANNUALS[i][1].format(2, '.');\n\t\t\tprint(p, \"\\t\"); free(p);\n\t\t\tchar* p2 = ANNUALS[i][2].format(2, '.');\n\t\t\tif (strlen(p2) \u003c 8) print(\"  \");\n\t\t\tprint(p2, \"\\t\"); free(p2);\n\t\t\tchar* p3 = ANNUALS[i][3].format(2, '.');\n\t\t\tprint(p3, \"\\n\"); free(p3);\n\t\t}\n\t\tfor (int i = 0; i \u003c YEARS; i++) {\n\t\t\tSQUARENESS_1 += ANNUALS[i][1];\n\t\t\tSQUARENESS_2 += ANNUALS[i][2];\n\t\t\tSQUARENESS_3 += ANNUALS[i][3];\n\t\t}\n\t\tprint(\"--------------------------------------------------\\n\");\n\t\tprint(\"       \");\n\t\tchar* p = SQUARENESS_1.format(2, '.');\n\t\tprint(p, \"      \"); free(p);\n\t\tchar* p2 = SQUARENESS_2.format(2, '.');\n\t\tprint(p2, \"       \"); free(p2);\n\t\tchar* p3 = SQUARENESS_3.format(2, '.');\n\t\tprint(p3, \" \"); free(p3);\n\t\tNUM SQUARENESS((SQUARENESS_1 + SQUARENESS_2 == SQUARENESS_3 - ANNUAL_CONTRIBUTION * YEARS));\n\t\tprint(\" =\u003e SQUARENESS=\", (SQUARENESS ? \"SUCCESS\" : \"FAILURE\"), \"\\n\");\n\t}\n\t\n\tint main() {\n\t\tasset(); //FUNCTION CALL \n\t\t\n\t\treturn 0;\n\t}\n\t/* Video output:\n\t\n\t\t 1   10.000,00      725,00   11.725,00\n\t\t 2   11.725,00      850,06   13.575,06\n\t\t 3   13.575,06      984,19   15.559,25\n\t\t 4   15.559,25    1.128,05   17.687,30\n\t\t 5   17.687,30    1.282,33   19.969,63\n\t\t 6   19.969,63    1.447,80   22.417,43\n\t\t 7   22.417,43    1.625,26   25.042,69\n\t\t 8   25.042,69    1.815,60   27.858,29\n\t\t 9   27.858,29    2.019,73   30.878,02\n\t\t10   30.878,02    2.238,66   34.116,68\n\t\t------------------------------------------------------------\n\t\t194.712,67   14.116,68  218.829,35 =\u003e SQUARENESS=SUCCESS\t*/\n \nROUNDING TYPES:\n\n\tNUM r(\"2.85\"), //DECLARATION AND INITIALIZATION \n\t\tarea(r * r * pi()), \n\t\ttemp(area), temp2(area); \n\tprint(area, \"\\n\");                                   //25.51758632878309557941282088068773875 \n\tprint(\"\\n---- NUM floor    rounding ----\\n\"); \n\tprint(area.round_floor(1), \" (1 decs)\\n\");         //25.5 (1 decs) \n\tprint(\"\\n---- NUM ceil     rounding ----\\n\"); \n\tprint(temp.round_ceil(1), \" (1 decs)\\n\");        //25.6 (1 decs) \n\tprint(\"\\n---- NUM standard rounding ----\\n\"); \n\tprint(temp2.round(2), \" (2 decs)\\n\");          //25.52 (2 decs) \n\tprint(\"\\n---- NUM bank     rounding ----\\n\"); \n\tprint(temp2.round_bank(-1), \" (united )\\n\"); //20.0 (united) \n\nARBITRARY PRECISION ARITHMETIC:\n\n\tNUM a(\"18446744073709551615.05\"), b(\"79557855184810661726.96\"); //DECLARATION AND INITIALIZATION \n\ta.print(\" \"); b.print(\" operands\\n\"); //18446744073709551615.05 79557855184810661726.96 operands\n\tadd(a, b).print(\" sum\\n\");           //98004599258520213342.01 sum\n\tsub(a, b).print(\" dif\\n\");          //-61111111111101110111.91 dif\n\tmul(a, b).print(\" pro\\n\");         //1467583393647448798475303745564903690126.748 pro\n\tdiv(a, b).print(\" quo\\n\");        //0.2318657790718249449152307927340895034397 quo\n\tmod(a, b).print(\" rem\\n\");       //18446744073709551615.05 rem\n\tprint(\"-----------------------------------------\\n\");\n\ta = 3; b = 100; //INITIALIZATION \n\ta.print(\" \"); b.print(\" operands\\n\"); //3.0 100.0 operands\n\tpow(a, b).print(\" exp\\n\"); \t     //515377520732011331036461129765621272702107522001.0 exp\n\nSCIENTIFIC NOTATION AND HIGH PRECISION RESULTS:\n\n\tNUM a(\"1.23456789\"),     //STANDARD NUMERIC NOTATION \n\t\tb(\"9.87654321\"),\t\t\t\t\t\t\t \n\t\tMUL(a * b);    //MULTIPLICATION \n\tdouble ieee754 = 1.23456789 * 9.87654321; \n\tNUM c; c.from_double(ieee754); \n\tprint(c,   \"  =\u003e MUL ieee754 - PRECISION FAILURE\\n\"); //12.193263111263525  =\u003e MUL ieee754 - PRECISION FAILURE \n\tprint(MUL, \" =\u003e MUL num7.h  - PRECISION SUCCESS\\n\"); //12.1932631112635269 =\u003e MUL num7.h  - PRECISION SUCCESS \n\tprint(\"-----------------------------------------\\n\"); \n\n\ta = \"1.23456789e300\";                        //SCIENTIFIC NUMERIC NOTATION \n\tb = \"9.87654321e300\"; \n\tieee754 = 1.23456789e300 * 9.87654321e300; //MULTIPLICATION \n\tprint(from_double(ieee754), \"\t\t\t=\u003e MUL ieee754 - CAPACITY FAILURE\\n\"); \n\tMUL = a * b;         \n\tchar* p = MUL.to_sci(); \n\tprint(p, \" =\u003e MUL num7.h  - PRECISION SUCCESS\\n\"); free(p); //inf\t\t\t=\u003e MUL ieee754 - CAPACITY FAILURE \n\tprint(\"-----------------------------------------\\n\");      //1.21932631112635269e601 = \u003e MUL num7.h - PRECISION SUCCESS \n \ndouble TO NUM CONVERSION ARRAY:\n\n\tdouble listing[] = { 5.14, -2.1, 5.0, -2543.9935500002972, -0.02 }; \n\tNUM L[5]; \n\tint elements = sizeof(listing) / sizeof(listing[0]); \n\tprint(\"elements=\"); print(elements, \"\\n\"); //elements=5\n\tprint(\"----------------------\\n\"); \t  //----------------------\n\n\tfor (int i = 0; i \u003c elements; i++)  \n\t\tL[i] = L[i].from_double(listing[i]).round(5); //RECTIFIED BINARY APPROXIMATION! \n\tfor (NUM l : L) print(l, \"\\n\"); //5.14 -2.1 5.0 -2543.99355 -0.02\n\tprint(\"----------------------\\n\\n\"); \n\n EFFECTIVE EXPRESSIONS NEED OF TEMPORARY VARIABLES:\n\n\tNUM base(3), h(4);\t\t\t\t                            //RIGHT-ANGLE TRIANGLE BASE AND HEIGHT\n\tNUM b2, h2;\t\t\t\t\t                                 //TEMPORARY VARIABLES\n\tprint(\"base = \", base, \"  h = \"); print(h, \"\\n\");   //base = 3.0  h = 4.0\n\tNUM hyp = sqr((b2 = base.x2()) + (h2 = h.x2()));   //PYTHAGOREAN EXPRESSION NEEDS OF TEMPORARY VARs\n\tprint(\"HYPOTENUSE = \"); hyp.print(\"\\n\");\t        //HYPOTENUSE = 5.0\n\tNUM AREA = base * h / 2;\t\t\t                   //AREA EXPRESSION\n\tprint(\"AREA = \"); AREA.print(\"\\n\");\t            //AREA = 6\n\n ERROR HANDLING:\n\n\t#include \"num7.h\"\n\t#include \u003ctime.h\u003e\n\tusing namespace num7;\n\n\tint main() {\n\t\tclock_t tic = clock(), toc = tic;\n\t\ttic = clock();\n\n\t\tNUM base = \"3\", h = \"4\";                           //SYNTAX ERROR, RIGHT-ANGLE TRIANGLE BASE AND HEIGHT (ERROR ARGUMENT VALUE =\u003e NUM CONSTRUCTOR: [3])\n\t\tif (error()) {                                    //DETECT ERRORs (ERROR ARGUMENT VALUE =\u003e NUM CONSTRUCTOR: [4])\n\t\t\tprint(\"INITIALIZATION VARIABLEs ERROR\\n\");\n\t\t\tbase = \"3.0\"; h = \"4.0\";\t\t                  //SYNTAX OK\n\t\t\terror_clear();                               //CLEAR ERROR\n\t\t}\n\t\tNUM b2, h2;\t\t\t\t\t                                //TEMPORARY VARIABLES\n\t\tprint(\"base = \", base, \"  h = \"); print(h, \"\\n\");  //base = 3.0  h = 4.0\n\t\tNUM hyp = sqr((b2 = base.x2()) + (h2 = h.x2()));  //PYTHAGOREAN EXPRESSION NEEDS OF TEMPORARY VARs\n\t\tprint(\"HYPOTENUSE = \"); hyp.print(\"\\n\");\t       //HYPOTENUSE = 5.0\n\t\tNUM AREA = base * h / 2;\t\t\t                  //AREA EXPRESSION\n\t\tprint(\"AREA = \"); AREA.print(\"\\n\");\t           //AREA = 6\n\t\tprint(\"---------------------\\n\");\n\n\t\ttoc = clock();\n\n\t\tprintf(\"---------------------\\n\");\n\t\tprintf(\"ET: %.6fs\", (double)(toc - tic) / CLOCKS_PER_SEC);\n\t\ttime_t now = time(NULL);\n\t\tchar* s_now = ctime(\u0026now);\n\t\tprintf(\"\\n%s*** PROGRAM OVER ***\\n\", s_now);\n\n\t\treturn 0;\n\t}\n\n### FAQ \n\nQ. I usually try to add 0.1 to 0.2 in C++ with this code:  \n\n\tdouble a = 0.1, b = 0.2;\n\tprintf(\"%d\\n\", a + b == 0.3);   //0 =\u003e false\nand the comparing number result is:  \n\n\t0 (false)  \n\t\nHow instead can it gets exactly 0.3?  \nA. Using NUM class:  \n\n\tNUM A(\"0.1\"), B(\"0.2\");\n\tprint(A + B == \"0.3\", \"\\n\"); //1 =\u003e true\nthe comparing number result is:\n\n\t1 (true)\n\t\nQ. I have two double variables in my code:  \n\n\tdouble a = 123456.123, b = -123456789.123456;\n\t\nHow can i convert them in NUM type with exact decimal digits?  \nA. With from_double() and round() in-line functions:\n\n\tdouble a = 123456.123, b = -123456789.123456; \n\tNUM A, B; \n\tconst int MAX_DECIMAL_PRECISION = 6; \n\tA = A.from_double(a).round(MAX_DECIMAL_PRECISION);  \n\tB = B.from_double(b).round(MAX_DECIMAL_PRECISION);  \n\tA.print(\"\\n\");    // 123456.123 \n\tB.print(\"\\n\"); //-123456789.123456 \n\nQ. I must enter many integer variables in my code:  \n\n\tNUM a(\"123.0\") , b(\"456.0\"), c(\"789.0\"); \n\t\nCan i input them without double quotes and suffix .0?  \nA. Yes, this the way:\n\n\tNUM a(123), b(456), c(789);  \n\nQ. I need managing zero division error in C++; How can do it?  \nA. num7 library supports hi-level execution workflow code for arithmetic operation errors:\n\n\t#include \"num7.h\"\n\t#include \u003ctime.h\u003e\n\tusing namespace num7;\n\n\tint main() {\n\t\tclock_t tic = clock(), toc = tic;\n\t\ttic = clock();\n\n\t\tNUM a(\"3.6\"), b(\"0.00\");\n\t\tprint(a, \" / \"); print(b, \" = \");\n\t\tNUM c(a / b); //ERROR DIVISION BY ZERO =\u003e operator/: [S=0 CE=0.0e0 C=0.0 E=0 len_I=1 len_F=1]\n\t\twhile (error()) {\t\t                        //!!! EXCEPTION HANDLER !!!\n\t\t\tstatic int err_count = 1;                //DECLARATION AND INITALIZATION\n\t\t\terror_clear(); \t\t\t                    //CLEAR ERROR (Error = 0) =\u003e GLOBAL VARIABLE\n\t\t\tif (err_count == 1) b = \"0.00\";        //ZERO DIVISON AGAIN (NOT VALID DIVISOR)\n\t\t\telse b = \"0.16\";\t\t                  //VALID DIVISOR\n\t\t\tprint(a, \" / \"); print(b, \" = \");\n\t\t\tc = a / b;\n\t\t\tif (err_count \u003e 2) { print(\"SYSTEM RESET\\n\"); break; } //3 TIMES RETRIES AT ALL\n\t\t\terr_count++;\n\t\t}\n\t\tif (!error()) print(c, \"\\n\"); //3.6 / 0.16 = 22.5 //OK\n\t\telse { print(\"SYSTEM RESET -EXIT\\n\"); return 1; }\n\t\tprint(\"---------------------\\n\");\n\n\t\ttoc = clock();\n\n\t\tprintf(\"---------------------\\n\");\n\t\tprintf(\"ET: %.6fs\", (double)(toc - tic) / CLOCKS_PER_SEC);\n\t\ttime_t now = time(NULL);\n\t\tchar* s_now = ctime(\u0026now);\n\t\tprintf(\"\\n%s*** PROGRAM OVER ***\\n\", s_now);\n\n\t\treturn 0;\n\t}\n\nQ. I need getting result in scientific notation; How can code it?   \nA. With the following code:\n\n\tNUM a(\"85.0e1900\"), b = \"13.0e1940\", PRO = a * b; \n\tPRO = PRO.into_sci();\n\tPRO.print_exp(\"\\n\"); //1.105e3843\n\t//PRO.print(\"\\n\");  //STANDARD NUMERIC NOTATION\t1105...0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiocip%2Fmacos_num7","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiocip%2Fmacos_num7","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiocip%2Fmacos_num7/lists"}