Asked by mark

i was given this program by my teacher. it converts decimal number to binary number.. Why is that FIX kept in front of (n/2) ...6th line of the program. why is that FIX written and why? i didn't get it

CLS
INPUT “ENTER A NUMBER”; N
WHILE N <> 0
A = N MOD 2
B$ = STR$(A)
N = FIX(N / 2)
C$ = B$ + C$
WEND
PRINT “BINARY EQUIVALENT IS”; C$
END

Answers

Answered by Reiny
Both the Int(Number) and Fix(Number) functions remove the fractional part of Number and return the resulting integer value.
The difference between Int and Fix functions is that if Number is negative, Int returns the first negative integer less than or equal to Number, whereas Fix returns the first negative integer greater than or equal to Number. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

source:
https://msdn.microsoft.com/en-us/library/xh29swte(v=vs.90).aspx
Answered by mark
thank you very much
There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions