Write a program or function that takes in positive integers a
, b
and c
, and prints or returns a/b
to c
decimal places, using the operations +-*/% [add, subtract, multiply, divide, modulate] on the positive integers: you can use all that your language allows, but not on floating point numbers. The range of a,b,c would be the range allowed for unsigned integers in your language.
The number result will be truncated to the last digit to print (so no round
).
This means that if your language does not have an integer type (only float), you can participate by using these float numbers as positive integers only. The clue of this exercise it would be to write the function that find the digits in a float point division, using only the operation +-*/% on [unsigned] integers.
Examples
print(1,2,1)
would print0.5
print(1,2,2)
would print0.50
print(13,7,27)
would print1.857142857142857142857142857
print(2,3,1)
would print0.6
print(4,5,7)
would print0.8000000
print(4,5,1)
would print0.8
print(9999,23,1)
would print434.7
print(12345613,2321,89)
would print if your Language has 32 bit unsigned5319.09220163722533390779836277466609220163722533390779836277466609220163722533390779836277466
The shortest code in bytes wins. I'm sorry if this appear not clear... I don't know languages too, not remember words well... It is better to have one link to Ideone.com or some other place for easily try the answer especially for to test some input different from proposed.
(1,2,0)
. See meta.codegolf.stackexchange.com/a/5608/194 \$\endgroup\$(1,2,0)
? \$\endgroup\$(1,2,0)
should be irrelevant since0
is not a positive integer. And I'd prefer it if c remains like that since I'd prefer not having to think about appending a.
or not \$\endgroup\$