Re: (parse-decimal-fraction <string>) --> <rational> ?



In article <47f3b04d$0$90267$14726298@xxxxxxxxxxxxxxx>,
"Alex Mizrahi" <udodenko@xxxxxxxxxxxxxxxxxxxxx> wrote:

??>> (defun parse-decimal-fraction (str)
??>> (let* ((dotpos (position #\. str))
??>> (left (subseq str 0 dotpos))
??>> (right (subseq str (1+ dotpos))))
??>> (+ (parse-integer left)
??>> (/ (parse-integer right)
??>> (expt 10 (length right))))))

LB> (defun parse-decimal-fraction (str &key (start 0) end (radix 10))
LB> (let ((dotpos (position #\. str :start start :end end)))
LB> (+ (parse-integer str :start start :end dotpos :radix radix)
LB> (/ (parse-integer str :start (1+ dotpos) :end end :radix radix)
LB> (expt 10 (- (or end (length str)) (1+ dotpos)))))))

(expt radix .. ), i guess.

Isn't it an oxymoron to have the word "decimal" in the name, but then
make the radix a parameter? Doesn't "decimal" mean "base 10"?

I guess in this context it's just intended to refer to the use of "." as
the separator between the integer and fraction component. Is there a
generic term for this delimiter? "Radix point"?

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages

  • Re: Limey - a pejorative?
    ... ask readers from the UK or those of English background if the ... asking is if someone could refer to you as "my limey friend," or is ... different context I'm reminded of Philip Pullman's Serafina Pekkala: ...
    (alt.usage.english)
  • Re: Hurwitz on Furtwangler
    ... following letters to be typed in ... the current context many use "pirate" to refer to those who merely ...
    (rec.music.classical.recordings)
  • Re: Possible with DOS Batch Programming?
    ... Without any quotation and thus no context the question is ... It could refer to some form of bread, ... Reply articles without context are definitely a PITA. ... Even with the foul and totally broken google ...
    (comp.programming)
  • Re: Moldavia Reminds russians To Leave
    ... J. Anderson wrote: ... >> You waste our time. ... What does 'our' mean in this context? ... Does it refer to the plurality ...
    (soc.culture.baltics)
  • Re: Copying paragraphs including formatting.
    ... >actually a shortcut. ... If you refer to an object in a context ... >in which an object can't be used directly, VB/VBA looks for the object's ...
    (microsoft.public.word.vba.beginners)