| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Fixing decimal return |
G'Day Garth,
-=> Quoting Garth Douglass to All <=-
GD> I was wondering if there is any way to fix the amount of
GD> decimal places thata float returns. For instance if it was
GD> a price being returned, to limit it toonly 2 decimal
GD> places. Any help with this would be very much appricated.
I don't think so.
You can however, use the printf's format specifier at output:
"%n.p" where n is the total width of the number and p is the dec.places.
Normally 7.2 is used for prices, that means xxxxx.xx .
eg.
price = 23.56789;
printf("Price = $%7.2f",price); output-> Price = $23.56
I'm not sure if the "%07.2f" works on floats, if it does then the 0 will
become a left fill for smaller than specified numbers.
The output then would become s'thing like 00023.56.
L8r Frank (fadam{at}ozemail.com.au).
___ Blue Wave/DOS v2.21
--- Gash
* Origin: The Software Parlour (3:635/544)SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 711/401 409 410 413 SEEN-BY: 711/430 808 809 932 934 712/515 713/888 714/906 800/1 @PATH: 635/544 50/99 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.