sail #'s
The primary purpose of sail #'s are for racing, and the numbers are assigned by the local YRA. The first few numbers are to designate which YRA region you are in, and then they are sequential. Some of the regions will allow you to request a specific # if it is not already taken (like your hull # or a previous winning sail #).
Otherwise, the sail #'s which reflect the hull # are generally informal "vanity" #'s for the owner. For cruising designs it was sometimes common for a production sailmaker to put the hull # on the sail if the factory sail purchase arrangment was written that way (MacGregor/Venture did this, and others as well), but if you have a a sail # which reflects your hull # and you decide to register with a local YRA, they will likely assign you a different sail #. You could request to use your hull # if it is on your sail, but this will only be approved if that # is not taken.
As I read this I realized I have confused everyone, but it has been a long week (just got back from the Ensenada Race)..
Oh well
Cheers!