Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!mips!yoyodyne!koblas From: koblas@mips.COM (David Koblas) Newsgroups: alt.sources Subject: Re: conv.c -- simple numeric base converter Message-ID: <39976@mips.mips.COM> Date: 8 Jul 90 20:27:15 GMT References: <18852@well.sf.ca.us> Sender: news@mips.COM Reply-To: koblas@mips.COM (David Koblas) Organization: MIPS Computer Systems, Sunnyvale, CA Lines: 88 Yet another base converter, but written as a replacement for atof. Called as: val = atov("0x123", 0); val = atov("abz", 36); Where the second argument is the default base, if == 0 then use default conventions: 0x = 16, 0 = 8, 0% = binary, else base 10. -----CUT---HERE---------------------------------------------------------- /* +------------------------------------------------------------------+ */ /* | Copyright 1989, David Koblas. | */ /* | You may copy this file in whole or in part as long as you | */ /* | don't try to make money off it, or pretend that you wrote it. | */ /* +------------------------------------------------------------------+ */ #include #ifdef TEST main(argc,argv) int argc; char **argv; { int i; for (i=1;i=type) goto out; val = (val*type)+n; } out: return(val * sign); } -- name : David Koblas domain: koblas@cs.uoregon.edu place: Nowhere, I'm just an AI batch job. domain: koblas@mips.com quote: "Time has little to do with domain: koblas@riacs.edu infinity and jelly donuts." domain: koblas@stellar.arc.nasa.gov