Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Code Samples & Tips
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.


Easter Day (calculation algorithm)


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-19-2008, 10:04 AM
maXim's Avatar
Senior Member
 
Join Date: May 2007
Location: Florence, Italy
Posts: 132
Send a message via MSN to maXim
Post Easter Day (calculation algorithm)

Hi Everyone,

a simple solution to detect the Easter day:
Attached Files
File Type: sbp easter_day.sbp (3.5 KB, 47 views)
Reply With Quote
  #2 (permalink)  
Old 03-19-2008, 03:43 PM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 423
Default

Ciao MaXim

Wow, your coding required a great deal of concentration.
Here is a shorter version:

Code:
Sub DateOfEaster(y)
  Dim c, n, k, i, j, l, m, d
  c = Int(y / 100)
  n = y - 19 * int( y / 19 )
  k = int(( c - 17 ) / 25)
  i = Int(c - int(c / 4) - ( c - k ) / 3 + 19 * n + 15)
  i = i - 30 * int( i / 30 )
  i = i - int(i / 28 ) * ( 1 - int( i / 28 ) * int( 29 / ( i + 1 ) ) * int( ( 21 - n ) / 11 ) )
  j = y + int(y / 4) + i + 2 - c + int(c / 4)
  j = j - 7 * int( j / 7 )
  l = i - j
  m = int(3 + (l + 40 ) / 44)
  d = l + 28 - 31 * int( m / 4 )
  if m = 3 Then Return "March " & d
  if m = 4 Then Return "April " & d
End Sub
Perhaps a later version of B4P will add the "\" operator.

Feel free to use or abuse

Roberto
Reply With Quote
  #3 (permalink)  
Old 03-19-2008, 04:01 PM
maXim's Avatar
Senior Member
 
Join Date: May 2007
Location: Florence, Italy
Posts: 132
Send a message via MSN to maXim
Post

Hi Roberto,

You are right, but my intention was to save memory (3 variables instead of 8 and only two expressions for calculating = -24/-36 bytes in RAM, approximately). However, a similar version I had already published: http://www.basic4ppc.com/forum/showt...0661#post10661.

Massimo

Last edited by maXim : 03-19-2008 at 04:21 PM.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Eigenvalue and Eigenvector calculation klaus Questions & Help Needed 9 01-21-2008 06:29 AM
Crypto - Which algorithm is used? Nycran Questions & Help Needed 12 12-09-2007 07:45 PM
Natural frequency calculation of mechanical structures klaus Share Your Creations 4 12-01-2007 01:49 PM
Natural frequency calculation of mechanical structures klaus Share Your Creations 0 11-29-2007 05:09 PM


All times are GMT. The time now is 06:19 PM.


Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0