Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
January 17, 2004 float to char[] | ||||
---|---|---|---|---|
| ||||
Is there a function, or what is considered the best way, to convert a float to a char[]? any help is appreciated Phill. |
January 17, 2004 Re: float to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Phill | It's been awhile, but float f; char sz[101]; sprintf(sz, "%G", f); "Phill" <phill@pacific.net.au> wrote in message news:bua4bf$2njm$1@digitaldaemon.com... > Is there a function, or what is considered the > best way, to convert a float to a char[]? > > any help is appreciated > > Phill. > > > |
January 17, 2004 Re: float to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | Thanks mate! (:o)) Phill. "Matthew" <matthew.hat@stlsoft.dot.org> wrote in message news:bua595$2p66$1@digitaldaemon.com... > It's been awhile, but > > float f; > char sz[101]; > sprintf(sz, "%G", f); > > "Phill" <phill@pacific.net.au> wrote in message news:bua4bf$2njm$1@digitaldaemon.com... > > Is there a function, or what is considered the > > best way, to convert a float to a char[]? > > > > any help is appreciated > > > > Phill. > > > > > > > > |
January 17, 2004 Re: float to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Phill | Phill <phill@pacific.net.au> wrote: > Is there a function, or what is considered the > best way, to convert a float to a char[]? > > any help is appreciated Depends on what you want to do and what your formatting needs happen to be. sprintf() works fine and its quick and dirty. You can probably do better by looking around at other library's source code for floating point conversion (e.g., FreeBSD's sprintf(), glibc's sprintf(), etc.) and writing your own conversion shim. -scooter -- Scott Michel | No research proposal ever survives UCLA Computer Science | contact with implementation. PhD Graduate Student | !! Futuaris nisi irrisus ridebis !! |
January 17, 2004 Re: float to char[] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Scott Michel | sprintf if fine, Im just making a simple calculator for my first outing with the D language. Thanks ! Phill. "Scott Michel" <scottm@mordred.cs.ucla.edu> wrote in message news:buac8r$68q$1@digitaldaemon.com... > Phill <phill@pacific.net.au> wrote: > > Is there a function, or what is considered the > > best way, to convert a float to a char[]? > > > > any help is appreciated > > Depends on what you want to do and what your formatting needs happen to be. > sprintf() works fine and its quick and dirty. You can probably do better > by looking around at other library's source code for floating point > conversion (e.g., FreeBSD's sprintf(), glibc's sprintf(), etc.) and writing > your own conversion shim. > > > -scooter > -- > Scott Michel | No research proposal ever survives UCLA Computer Science | contact with implementation. PhD Graduate Student | !! Futuaris nisi irrisus ridebis !! > |
Copyright © 1999-2021 by the D Language Foundation