IonicWind Software

IWBasic => General Questions => Topic started by: Andy on July 26, 2013, 01:15:47 AM

Title: Day of week puzzle and work around
Post by: Andy on July 26, 2013, 01:15:47 AM
Hi,

This is a puzzle, although I have a work around for it (attached).

The code works fine in EB, but in IWB it doesn't.

Line causing the problem was:
N = 365 * Y + D + 31 * M + 2 - (M >= 3) * INT(.4 * M + 2.3) + INT(Y2 / 4) - INT(.75 + INT(Y2 / 100) * .75)

The actual problem was the "INT(.4 * M + 2.3)" - it should have a value say "5" and if you calculate it on its own you do get a value.

But added into the above "N = ..........." it does not?

I stored the value "c" to a string, then got the value of the string and stored it to another variable "p" and then put "p" into the calculation:

c = INT(.4 * M + 2.3)
c$ = STR$(c)
p = VAL(c$)

N = 365 * Y + D + 31 * M + 2 - (M >= 3) * p + INT(Y2 / 4) - INT(.75 + INT(Y2 / 100) * .75)

Now it works, but why? 
Andy.

Andy.
Title: Re: Day of week puzzle and work around
Post by: LarryMc on July 26, 2013, 07:18:39 AM
 ??? ??? ??? ??? ???
First, you don't need the C$ or p variables
just substituting c for INT(.4 * M + 2.3) will work

the puzzle is why does it equate to the proper value when you set it equal to c
yet when you insert it directly in the equation it always equates to zero

if you insert it directly in the equation but leave the INT off it does not evaluate to zero but is still off just a little.

Maybe LarryS can find time to look into it.

I don't have a clue other than that imbedded INT isn't doing what it should be doing. ??? ??? ???
Title: Re: Day of week puzzle and work around
Post by: Andy on July 26, 2013, 07:31:15 AM
Thanks Larry,

Thanks for looking at it, it's not a major problem but it could be in some other instance.

yes, it's a puzzle.

Thanks, as always,
Andy.
:)
Title: Re: Day of week puzzle and work around
Post by: Bill-Bo on July 26, 2013, 02:19:14 PM
I have attached an eba file with a formula that be can be
use in most any basic. I've used the formula for years.

Bill

P.S. Any questions, let me know.