On Wed, Jun 11, 2008 at 2:19 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: > 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 > > >
Thanks Rob, My misgivings revolved around using string concatenation to create numbers. Not misgivings, really. just the suspicion that there should be a way to handle numbers as numbers from start to finish--e.g., something roughly the opposite of POSIX::frexp()--and the nagging feeling that I'd missed something obvious. --j -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!