I'm trying to get an ESP32 to calculate Zeller's congruence.
This calculates a number that represents the weekday for a certain date.
https://en.wikipedia.org/wiki/Zeller%27s_congruence
I have tried several methods for calculation but it doesn't always return the right number.
In this example I have variables (not shown) for the day, month and year.
If I calculate the Zeller number, it doesn't always work.
I have tried local variables (.val1 ... .val8) as integer, as float and so on.
What can I try next?
This is one of my latest versions where I tested the variables with Floats..
Any suggestions?
Math help wanted: Zeller congruence
-
- Posts: 278
- http://meble-kuchenne.info.pl
- Joined: Tue Dec 08, 2020 5:11 pm
- Has thanked: 81 times
- Been thanked: 57 times
-
- Valued Contributor
- Posts: 1281
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 312 times
- Been thanked: 452 times
Re: Math help wanted: Zeller congruence
Hi
Sorry to be brief, it's stupid O' clock and I'm heading out soon.
Very interesting little project. I would break the calculation down into individual steps containing one action (calculation) and then step through your chart checking each result is as expected. This would hopefully allow you to see where things are going astray.
I do notice that in your post you are assigning .val4 = .val3 /4 then in the next line assigning it to (year / 100). Haven't got time to check if that's correct but initially looks suspect.
Regards
Sorry to be brief, it's stupid O' clock and I'm heading out soon.
Very interesting little project. I would break the calculation down into individual steps containing one action (calculation) and then step through your chart checking each result is as expected. This would hopefully allow you to see where things are going astray.
I do notice that in your post you are assigning .val4 = .val3 /4 then in the next line assigning it to (year / 100). Haven't got time to check if that's correct but initially looks suspect.
Regards
-
- Matrix Staff
- Posts: 1560
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 555 times
- Been thanked: 514 times
Re: Math help wanted: Zeller congruence
Hello.
I have attached a Flowchart which is not Zeller congruence, but it does calculate the day of the week in any year from 1753 to 2699.
I don't know if it will be useful for you.
I have attached a Flowchart which is not Zeller congruence, but it does calculate the day of the week in any year from 1753 to 2699.
I don't know if it will be useful for you.
- Attachments
-
- Day of the week.fcfx
- (21.26 KiB) Downloaded 126 times
Martin
Re: Math help wanted: Zeller congruence
@Both: Thanks for your reaction!
@chipfryer27 the example is my "disassembled" version of the Zeller congruence.
I've tried it in one calculation but this returned not always a good result.
That is why I decided to make the calculation again but step-by-step.
I can not figure out why this sometimes returns a good and why sometimes a bad result.
Is it because I use the wrong settings for the variables?
But even with a Float this should return a good result...
Strange
@medelec35 Thanks for the example.
You won't believe this but this was something I already started with.
But, this seemed a bit overkill for me
I appreciate this, and maybe, if I can't the Zeller one to work, I will use this one.
Still I wonder why the Zeller doesn't work...
Any suggestions?
@chipfryer27 the example is my "disassembled" version of the Zeller congruence.
I've tried it in one calculation but this returned not always a good result.
That is why I decided to make the calculation again but step-by-step.
I can not figure out why this sometimes returns a good and why sometimes a bad result.
Is it because I use the wrong settings for the variables?
But even with a Float this should return a good result...
Strange
@medelec35 Thanks for the example.
You won't believe this but this was something I already started with.
But, this seemed a bit overkill for me
I appreciate this, and maybe, if I can't the Zeller one to work, I will use this one.
Still I wonder why the Zeller doesn't work...
Any suggestions?
-
- Matrix Staff
- Posts: 1560
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 555 times
- Been thanked: 514 times
Re: Math help wanted: Zeller congruence
The experessions are simplified compared to Zeller congruence in my eyes, but I have place one expression in their own clacluatio box so help you single step to see how it all works.
Of couse you don't need the function call, I added it for my benefit.
I would try without floats.
You don't need floor as the equivalent of floor is just a variable e.g byte, int or uint.
For example if you had intA= 11 and intB = 4
Then result of intA/intB = 2
That is the floor of 2.75
Martin