So I have a double set to equal 1234, I want to move a decimal place over to make it 12.34
So to do this I multiply .1 to 1234 two times, kinda like this
<
In financial software it is common to use integers for pennies. In school, we were taught how to use fixed-point instead of floating, but that is usually powers of two. Storing pennies in integers might be called "fixed point" as well.
int i=1234;
printf("%d.%02d\r\n",i/100,i%100);
In class, we were asked in general what numbers can be exactly represented in a base.
For base=p1^n1*p2^n2
... you can represent any N where N=n*p1^m1*p2^m2.
Let base=14=2^1*7^1
... you can represent 1/7 1/14 1/28 1/49 but not 1/3
I know about financial software -- I converted Ticketmaster's financial reports from VAX asm to PASCAL. They had their own formatln() with codes for pennies. The reason for the conversion was 32 bit integers were no longer enough. +/- 2 billion pennies is $20 million and that overflowed for the World Cup or Olympics, I forgot.
I was sworn to secrecy. Oh well. In academea, if it's good you publish; in industry, you keep it secret.