Good afternoon.
An internet exercise asks you to calculate how much time a given investment can pay a debt, both growing at an interest rate per month.
Notice the procedure created
declare @divida real = 10000
declare @aplicacao real = 1500
declare @taxa_div real = 0.025
declare @taxa_apli real = 0.04
declare @meses int = 1
while (@divida > @aplicacao) begin
set @divida = (@divida * @taxa_div) + @divida
set @aplicacao = (@aplicacao * @taxa_apli) + @aplicacao
set @meses = @meses + 1
end
print @meses
select @divida
select @aplicacao
print @divida
print @aplicacao
print @aplicacao - @divida
At the end I'm displaying the values when I noticed the following points:
- At the end when I ask to display the values with the PRINT is not displayed with decimal places already, using the SELECT the decimal places are displayed.
- When I ask you to subtract the values, the result is displayed with decimal places.
Does anyone have an idea of the pq?