Modulo on a big number

lightning
Member Posts: 15
Hi,
I need to perform a modulo operation on a very big number (30 digits, could even be all 9's), is it even possible to do that in Navision?
If so, how would i do that? It would be a simple VARIABLE MOD 97 operation.
Also, the 'number' is stored in a Text variable, since obviously integer can't hold a number of this magnitude
I need to perform a modulo operation on a very big number (30 digits, could even be all 9's), is it even possible to do that in Navision?
If so, how would i do that? It would be a simple VARIABLE MOD 97 operation.
Also, the 'number' is stored in a Text variable, since obviously integer can't hold a number of this magnitude
0
Answers
-
Nope. Such a large number cannot be represented on a regular PC.
'Standard' arithmetic is limited to 64bits which is about 16 digits in case of double precision decimal, or 19 digits for big integer.
Maybe some specialistic math software can handle it, NAV is not an exampe of one...Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
OBJECT Codeunit 50000 BigInteger { OBJECT-PROPERTIES { Date=; Time=; Version List=; } PROPERTIES { OnRun=VAR BigInteger@50000 : DotNet "'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Numerics.BigInteger"; aResult@50001 : Text; aInteger@50002 : Integer; BEGIN aResult := BigInteger.Remainder(BigInteger.Parse('999999999999999999999999999999'),BigInteger.Parse('97')).ToString(); EVALUATE(aInteger,aResult); MESSAGE('%1',aInteger); //84 END; } CODE { BEGIN END. } }
Edit: Oh, classic forum... Then it works only when using the 2009 RTC.0 -
Found a way, here's the code:
WHILE STRLEN(CheckSumCalculator) > 6 DO CheckSumCalculator := CalculateModulus(COPYSTR(CheckSumCalculator,1,6), 97) + COPYSTR(CheckSumCalculator, 7) EVALUATE(ToInt, CheckSumCalculator); ToInt := ToInt MOD 97;
And the CalculateModulus procedureEVALUATE(I,Number); I := I MOD Modulus; IF I = 0 THEN EXIT(''); EXIT(FORMAT(I));
I took the solution from "CheckIBAN" from NAV2017
2 -
@Duikmeester
Even in 3Tier - are you sure the results are correct?aResult := BigInteger.Remainder( BigInteger.Parse('979999990000000000000000000000'), BigInteger.Parse('97')).ToString(); aResult2 := BigInteger.Remainder( BigInteger.Parse('979999990000000000000000000001'), BigInteger.Parse('97')).ToString(); EVALUATE(aInteger2,aResult2); MESSAGE('%1, %2',aInteger, aInteger2); //0, 69
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
1
-
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions