Logo

Programming-Idioms

History of Idiom 76 > diff from v72 to v73

Edit summary for version 73 by programming-idioms.org:
[Fortran] 2 ways => 2 distinct entries please. See impl 4338

Version 72

2020-11-25, 22:09:34

Version 73

2020-11-25, 22:10:11

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Variables
s,x
Variables
s,x
Extra Keywords
int radix
Extra Keywords
int radix
Code
write (unit=s,fmt='(B0)') 13 ! just the string length
write (unit=s,fmt='(B32)') 13 ! Fills it up with zeros
Code
write (unit=s,fmt='(B0)') x