|
-
Mar 9th, 2019, 06:13 PM
#1
Re: [RESOLVED] Weird Math Error in VBA for Excel
The code doesn't seem to match the Excel formula. In the code, you are doing two separate mods, in the Excel formula, you are doing only one mod.
Setting that aside, as I guessed, there is an order of operations issue.
With the Excel formula, this is the order things are happening:
1. The value in B2 is squared
2. That result is divided by the value in B3
3. That result is then taken MOD of the value in B4
In the VBA code you posted, the MOD is happening at step 2, and step 3 is the division. That is why you are seeing different results. The power being an integer or not is not the issue based on what you have posted.
-
Mar 9th, 2019, 06:33 PM
#2
Thread Starter
Junior Member
Re: [RESOLVED] Weird Math Error in VBA for Excel
Hi Sorry, had multiple copies of code I was testing and pasted the wrong copy, the correct one is shown above.
The thing is the code as is will work IF only integers are used and it will match the spreadsheet based mod formulas,
divergence to error only occurs if I use rationals for the power value and or divisor value, that is the only time it
fails
-
Mar 9th, 2019, 06:48 PM
#3
Thread Starter
Junior Member
Re: [RESOLVED] Weird Math Error in VBA for Excel
Hi Sorry, had multiple copies of code I was testing and pasted the wrong copy, the correct one is shown above.
The thing is the code as is will work IF only integers are used and it will match the spreadsheet based mod formulas,
divergence to error only occurs if I use rationals for the power value and or divisor value, that is the only time it
fails
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|