[aprssig] perl Geo::Ellipsoid

Tom Hayward esarfl at gmail.com
Wed May 4 10:41:00 EDT 2011


On Wed, May 4, 2011 at 08:32, Andrew Rich <vk4tec at tech-software.net> wrote:
> Wonder is someone can help
>
> I want to format a number in perl
>
> 3 leading 0 padded
> 2 trailing decimal places
>
> Do I have to treat to the left of the decimal point and to the right as two
> seperates ?
>
> I want 3.4565443 to look like "003.456"
>
> Working on some GPS code
>
> Using sprintf
>
> This puts 3 leading and zero pads:-
>
> $dist = sprintf("%3d",$dist);
> $bearing = sprintf("%3d",$bearing);

Quite off-topic at this point ;)

You want "%07.3f". That's leading zeros, a total of 7 characters
(includes decimal point), and 3 digits following the decimal.

Tom KD7LXL




More information about the aprssig mailing list