Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P 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
Basic4ppc Veteran
 
Join Date: May 2007
Location: Sesto Fiorentino - Florence (Italy)
Posts: 224
Send a message via MSN to maXim Send a message via Skype™ to maXim
Awards Showcase
Beta Tester 
Total Awards: 1
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, 100 views)
Reply With Quote
  #2 (permalink)  
Old 03-19-2008, 03:43 PM
alfcen's Avatar
Basic4ppc Expert
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu Islands
Posts: 810
Send a message via Skype™ to alfcen
Awards Showcase
Beta Tester 
Total Awards: 1
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 ) * int29 / ( 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
Basic4ppc Veteran
 
Join Date: May 2007
Location: Sesto Fiorentino - Florence (Italy)
Posts: 224
Send a message via MSN to maXim Send a message via Skype™ to maXim
Awards Showcase
Beta Tester 
Total Awards: 1
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Natural frequency calculation of mechanical structures klaus Share Your Creations 9 09-25-2009 07:24 PM
Eigenvalue and Eigenvector calculation klaus Questions (Windows Mobile) 9 01-21-2008 06:29 AM
Crypto - Which algorithm is used? Nycran Questions (Windows Mobile) 12 12-09-2007 07:45 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 09:49 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0