
660 P.2d 67 (1983)
104 Idaho 455
Roger LAW, Petitioner,
v.
Honorable Francis J. RASMUSSEN, Sixth Judicial District Judge, Respondent.
No. 14620.
Supreme Court of Idaho.
March 4, 1983.
*68 Gaylen L. Box, Pocatello, for petitioner.
Francis J. Rasmussen, respondent, pro se.
HUNTLEY, Justice.
Petitioner was found guilty of driving under the influence of an intoxicating beverage and possession of marijuana, both felonies,[1] and sentenced to a maximum term of five years' imprisonment for each offense, the terms to run concurrently. The court first suspended execution of the sentences and placed petitioner on probation. When he was later found guilty of violating his probation, the suspension order was revoked and the five-year sentences were imposed.
Petitioner made a timely motion for correction of sentence pursuant to I.C.R. 35, requesting that 186 days be subtracted from his five-year sentences, that being the length of time he was incarcerated prior to sentencing. The district court denied the motion and indicated that the 186 days had been considered at the time the sentences were imposed. Petitioner then made a pro se application to this court for a writ of mandate directing the district judge to credit the pre-sentence incarceration time toward his prison sentences.
The petition raises two questions which must be considered. The first is whether a person has received credit for pre-sentence incarceration as required by I.C. § 18-309 when the trial court considers the confinement in determining to suspend the sentence and place him on probation, but does not apply the confinement time against the sentence to be imposed if probation is revoked. The second question is whether mandamus will lie to correct an alleged denial of petitioner's statutory rights.
I.C. § 18-309 provides, in part:
"In computing the term of imprisonment, the person against whom the judgment was entered, shall receive credit for any period of incarceration prior to entry of judgment, if such incarceration was for the offense or an included offense for which the judgment was entered."
Respondent contends that a defendant is given "credit" for presentence confinement if the trial judge takes it into consideration as a further inducement in granting probation. While it is desirable that a defendant be given this sort of "credit" for pre-sentence confinement, that is, have it taken into account as a factor favoring a grant of probation, it is important that he not be denied the more objective benefit intended by I.C. § 18-309. That statute requires a reduction in the time to be served equal to the amount of time already served. In other words, a prisoner's time owing, or *69 "negative balance," should not include time he has already paid. This is so as a matter of fairness, and it is what the legislature intended. See, State v. Waller, 97 Idaho 377, 544 P.2d 1147 (1946); State v. Hoch, 102 Idaho 351, 630 P.2d 143 (1981).
Because petitioner was given maximum sentences of five years for each offense, and was not given any reduction for presentence confinement, the term of imprisonment imposed exceeded the statutory maximum.[2] Petitioner was placed in the position of having to undergo confinement beyond the statutory maximum because he could not post bail to free himself prior to trial. Such a practice, if condoned, would raise serious constitutional questions. See, Williams v. Illinois, 399 U.S. 235, 90 S.Ct. 2018, 26 L.Ed.2d 586 (1970).
We hold, therefore, that I.C. § 18-309 requires the sentencing judge give credit for pre-sentence incarceration so as to reduce the convicted person's sentence by the amount of time that person has already spent in confinement, whether or not the person is granted probation. There is always the chance that probation will be revoked, as it was here, and the original sentence of imprisonment be reimposed.
We turn next to the second question: whether or not a writ of mandate will issue to compel respondent, a district judge, to credit petitioner's 186 days of pre-sentence confinement against his five-year prison sentence. We hold that it will.
Mandamus proceeds upon the assumption that the applicant has an immediate and complete legal right to the thing demanded, Reynard v. City of Caldwell, 53 Idaho 62, 21 P.2d 527 (1933), and will not lie to coerce or control discretion of the district court, Freeman v. McQuade, 80 Idaho 387, 331 P.2d 263 (1958). Where such a right exists, and is being withheld from the applicant, mandamus may be invoked. See, Farmer v. Loofbourrow, 75 Idaho 88, 267 P.2d 113 (1954) (stating that mandamus may be invoked to compel a judge to provide a defendant with a jury trial, "even though his refusal to do so is reversible on appeal").
As to the certainty of the right demanded, this court has stated:
"Lastly, we are not unmindful of the contention made by the attorney general, that the right to such a writ must be clear and beyond question. The correct and true rule in such matters seems to be this: If the doubt or uncertainty exists or inheres in the facts of the case, so that it does not appear clear that such facts entitle the plaintiff to relief by mandate, under any valid law, the writ will not issue. [Citations omitted.] But where the only doubt that clouds the issue consists in the construction of the statute which confers the right or imposes the duty, the writ will issue if the court, after considering the law, concludes that it confers the right claimed or imposes the duty asserted... ." Robinson v. Enking, 58 Idaho 24, 31-32, 69 P.2d 603, 606 (1937).
Petitioner seeks a writ commanding that the right to credit for pre-sentence incarceration, afforded him by statute, be provided. We consider this a proper case for mandamus, and in accordance with our holding above, grant the writ. I.C. § 7-302. The alternative writ of mandate is hereby made permanent.
DONALDSON, C.J., and SHEPARD, BAKES and BISTLINE, JJ., concur.
NOTES
[1]  I.C. §§ 49-1102(d), (e), and 37-2732(e), respectively.
[2]  While it might be argued that the judge's determination that the sentences were to run concurrently was a reduction in the time of imprisonment sufficient to account for presentence confinement credit, we note the sentencing judge's own declaration, in the Minute Entry and Order, that "[d]efendant shall not receive credit for time spent in jail during the pendency of this action." It was not his intention that the concurrent sentences serve as credit for prior confinement. In any case, "each conviction is separate and if the statutory maximum term is imposed, the order that the sentences run concurrently does not vitiate the contention that defendant received the maximum prison sentence." Lee v. United States, 400 F.2d 185, 188 (9th Cir.1968).
