Jay Savage wrote:
>
> I'm having trouble wrapping my brain around this:
> 
> I am writing a script that will receive two integers as input that
> represent a single float. The first is the integer part, the second is
> hat mantissa. How do I recomine them into a single float? all I'm
> coming up with so far is:
> 
> my $float = $int_part . '.' . $matissa; #or
> my $float = sprintf "%u.%u", $int_part, $mantissa;
> 
> It seems, though, like there should be a more elegant way to handle
> this than turning two numbers into a string to turn around and use the
> result as  number again. What am I missing?

Hi Jay

I don't think you're missing anything. I would write

  my $float = "$int_part.$mantissa";

which is the same as your first solution, but a little more concise.

I think this is very elegant indeed; please tell me about your misgivings?

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to