468,735 Members | 2,169 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,735 developers. It's quick & easy.

extract digits from a number ?

How to extract digits from a given number
say double number is 10.9876
extract two digits after decimal - 98
extract three digits after decimal - 987

and represent the extracted number as an integer.
Jul 22 '05 #1
1 6160
"mark" <ma*********@yahoo.com> wrote...
How to extract digits from a given number
say double number is 10.9876
extract two digits after decimal - 98
extract three digits after decimal - 987

and represent the extracted number as an integer.


double number = 10.9876;
int twodigits = int(floor(number * 100)) % 100;
int threedigits = int(floor(number * 1000)) % 1000;
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bernard Drolet | last post: by
7 posts views Thread by William Payne | last post: by
44 posts views Thread by RB | last post: by
27 posts views Thread by Luke Wu | last post: by
109 posts views Thread by jmcgill | last post: by
8 posts views Thread by Fabian Braennstroem | last post: by
reply views Thread by napolpie | last post: by
reply views Thread by zhoujie | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.