Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!ai-lab!rice-chex!bson From: bson@rice-chex.ai.mit.edu (Jan Brittenson) Newsgroups: comp.sys.handhelds Subject: Re: HP 48 Yards.FeetInches Message-ID: <16478@life.ai.mit.edu> Date: 13 Jun 91 23:39:24 GMT References: <2855ad7d:3432comp.sys.handhelds@hpcvbbs.UUCP> Sender: news@ai.mit.edu Organization: nil Lines: 54 In a posting of [12 Jun 91 05:40:05 GMT] akcs.joehorn@hpcvbbs.UUCP (Joseph K. Horn) writes: > +-----------------------------------------+ > | HMS->(x) = x + FP(x)/1.5 + FP(x*100)/90 | > +-----------------------------------------+ > My question is: If this kind of algorithm works for H.MS, can similar > ones be created for any arbitrary fractional systems, like > Yards.FeetInches? If so, how? How about: YFI->(x) = x + FP(x) * 7/3 + FP(x*10) * 22/9 Where YFI is: y.fii I.e. 1 yard, 2 feet, 5 inches = 1.205 --- So, how does it work? Pretty simple actually. The first term maps the integer part 1:1 (no conversion necessary). But it also maps the .f and ..ii parts 1:1, so they need some adjustment. Feet map 1:0.3, so as far as feet are concerned we fulfill the following equation to get the feet back in line: 1 = 0.3 + 0.3 * k ==> k = (1-0.3)/0.3 = 7/3 So we now have: YFI->(x) = x + FP(x) * 7/3 Note that we use FP() since we have already taken care of the integer part (which mapped 1:1). This also maps the ..ii part, so again we need to adjust it - we would like it to map 1:0.036 (i.e. 3 * 12in = 1ft): 1 = 0.036 + 0.036 * k + 0.36 * m ==> m = (1-0.036-0.036*7/3)/0.36 = 22/9 So now we have our final term. YFI->(x) = x + FP(x) * 7/3 + FP(x*10) * 22/9 We multiply by ten and discard the IP to get rid of what is already mapped. Apologies if this sounds confusing. -- Jan Brittenson bson@ai.mit.edu