Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Precision
#11
For more-accurate solutions, greater strength might be needed instead of "MOD":

https://www.unix.com/man-page/linux/3/fmod/

Likely the "fmodl()" out of them.

Some of the variables then have to be declared _INTEGER64 and others _DOUBLE or _FLOAT.
Reply
#12
(11-22-2022, 09:08 PM)Chris Wrote: How to apply dec float here? It only gives part of the code.


rplus1 = c1plus1 MOD 1095
rminus1 = c1minus1 MOD 1095
v1 = 32336 * q + INT((15 * q + 765433 * R + 12084) / 25920)
v1plus1 = 32336 * qplus1 + INT((15 * qplus1 + 765433 * rplus1 + 12084) / 25920)
v1minus1 = 32336 * qminus1 + INT((15 * qminus1 + 765433 * rminus1 + 12084) / 25920)
v2 = v1 + INT(6 * (v1 / 7)) MOD 2
v2plus1 = v1plus1 + INT(6 * (v1plus1 / 7)) MOD 2
v2minus1 = v1minus1 + INT(6 * (v1minus1 / 7)) MOD 2
L2 = v2plus1 - v2
L2minus1 = v2 - v2minus1
v3 = 2 * (INT((L2 + 19) / 15) MOD 2)
v4 = INT((L2minus1 + 7) / 15) MOD 2
c2 = v2 + v3 + v4
v3plus1 = 2 * (INT((L2plus1 + 19) / 15) MOD 2)
v4plus1 = INT((L2 + 7) / 15) MOD 2
c2plus1 = v2plus1 + v3 + v4
L = c2plus1 - c2
c8 = INT((L + 7) / 2) MOD 15
c9 = -(INT((385 - L) / 2) MOD 15)
c3 = INT((384 * x3 + 7) / 13) + c8 * INT((x3 + 4) / 12) + c9 * INT((x3 + 3) / 12)

Try here...

https://qb64phoenix.com/forum/showthread...13#pid7813
Reply
#13
(11-22-2022, 09:08 PM)Chris Wrote: How to apply dec float here? It only gives part of the code.


rplus1 = c1plus1 MOD 1095
rminus1 = c1minus1 MOD 1095
v1 = 32336 * q + INT((15 * q + 765433 * R + 12084) / 25920)
v1plus1 = 32336 * qplus1 + INT((15 * qplus1 + 765433 * rplus1 + 12084) / 25920)
v1minus1 = 32336 * qminus1 + INT((15 * qminus1 + 765433 * rminus1 + 12084) / 25920)
v2 = v1 + INT(6 * (v1 / 7)) MOD 2
v2plus1 = v1plus1 + INT(6 * (v1plus1 / 7)) MOD 2
v2minus1 = v1minus1 + INT(6 * (v1minus1 / 7)) MOD 2
L2 = v2plus1 - v2
L2minus1 = v2 - v2minus1
v3 = 2 * (INT((L2 + 19) / 15) MOD 2)
v4 = INT((L2minus1 + 7) / 15) MOD 2
c2 = v2 + v3 + v4
v3plus1 = 2 * (INT((L2plus1 + 19) / 15) MOD 2)
v4plus1 = INT((L2 + 7) / 15) MOD 2
c2plus1 = v2plus1 + v3 + v4
L = c2plus1 - c2
c8 = INT((L + 7) / 2) MOD 15
c9 = -(INT((385 - L) / 2) MOD 15)
c3 = INT((384 * x3 + 7) / 13) + c8 * INT((x3 + 4) / 12) + c9 * INT((x3 + 3) / 12)


All those Integer conversions suggest to me you are looking for _INTEGER64 Type for for maximum Integer range.
b = b + ...
Reply
#14
I have a # sign in my code next to each variable and there are errors. For the needs of the Forum, I have removed them. So, it is about floating point and xintegrate values depending on the formula.
Reply
#15
_DEFINE A-Z AS _FLOAT

did not help
Reply
#16
All those Integer conversions suggest to me you are looking for _INTEGER64 Type for for maximum Integer range.


And the results of this is?
Reply
#17
To sum up, in order not to extend it, write like this:
A ## = b ## / 548 * C ##
So double sign.
I'll check tomorrow. I am after 10 PM
Reply
#18
Out of this code:

Code: (Select All)
DIM li AS _INTEGER64
DIM lf AS _FLOAT
li = 9223372036854775806
lf = 9223372036854775806
PRINT li
PRINT lf

I get a "D+18" at the end of "lf" value. This was one less than the positive maximum value of 64-bit integer. I notice your calculations need negative numbers and that's why I tried previously with 18 trilliard and got instead "D+19" from the _FLOAT variable.

If only you could make sure you don't need a fractional part anywhere in your calculations, use _INTEGER64. This is because you said something about the astronomer and usually it means accuracy that could be offered by the "string math" solutions sprinkled on this forum. The "string math" is harder to program, indeed but gives much better accuracy for very small numbers than any simple variable storage type in any "unmanaged" programming language.
Reply
#19
(11-22-2022, 09:08 PM)Chris Wrote: How to apply dec float here? It only gives part of the code.


rplus1 = c1plus1 MOD 1095  ' what's c1plus???
rminus1 = c1minus1 MOD 1095 ' what's c1minus1 ???
v1 = 32336 * q + INT((15 * q + 765433 * R + 12084) / 25920)  ' what's q what's R ???
v1plus1 = 32336 * qplus1 + INT((15 * qplus1 + 765433 * rplus1 + 12084) / 25920) ' what's qplus1 ??? q -1
v1minus1 = 32336 * qminus1 + INT((15 * qminus1 + 765433 * rminus1 + 12084) / 25920)
v2 = v1 + INT(6 * (v1 / 7)) MOD 2
v2plus1 = v1plus1 + INT(6 * (v1plus1 / 7)) MOD 2
v2minus1 = v1minus1 + INT(6 * (v1minus1 / 7)) MOD 2
L2 = v2plus1 - v2
L2minus1 = v2 - v2minus1
v3 = 2 * (INT((L2 + 19) / 15) MOD 2)
v4 = INT((L2minus1 + 7) / 15) MOD 2
c2 = v2 + v3 + v4
v3plus1 = 2 * (INT((L2plus1 + 19) / 15) MOD 2)
v4plus1 = INT((L2 + 7) / 15) MOD 2
c2plus1 = v2plus1 + v3 + v4
L = c2plus1 - c2
c8 = INT((L + 7) / 2) MOD 15
c9 = -(INT((385 - L) / 2) MOD 15)
c3 = INT((384 * x3 + 7) / 13) + c8 * INT((x3 + 4) / 12) + c9 * INT((x3 + 3) / 12)

Really this chunk of code is missing allot of values that QB64 will assume as 0 if we just tested this part.
Where did this code come from? If some language with arbitrary large integers like Python then need string math.

Anyone see the calculations for Easter, this looks like Easter on a planet not in our solar system with q moons ;-))
b = b + ...
Reply
#20
Quote:rplus1 = c1plus1 MOD 1095
rminus1 = c1minus1 MOD 1095
v1 = 32336 * q + INT((15 * q + 765433 * R + 12084) / 25920)
v1plus1 = 32336 * qplus1 + INT((15 * qplus1 + 765433 * rplus1 + 120 ) / 25920)
v1minus1 = 32336 * qminus1 + INT((15 * qminus1 + 765433 * rminus1 + 12084) / 25920)
v2 = v1 + INT(6 * (v1 / 7)) MOD 2
. . .

What shoud that?
What is c1plus1, c1minus1, V1, V1plus1, qplus1, . . .
And mnrvovrfc is right: use DIM and Option _Explicit, otherwise the DIM has practically no value.
Reply




Users browsing this thread: 3 Guest(s)