JPhrases/Representations

From J Wiki
Jump to: navigation, search

8C. Representations

d0=: >:@<.@^. Length to represent y in base x
d1=: d0 # [ Base to represent integer y in base x
d2=: d1 #:] Base x rep of decimal integer y
m3=: #:@i.@>: Binary reps of integers from 0 to y
m4=: 10"_ d2 ] Base 10 rep of decimal integer y
m5=: 16"_ d2 ] Base 16 rep of decimal integer y
d6=: (>:@<.@^. # [) #: ] Base x rep of decimal integer y
d7=: ] #:~ >:@<.@^. # [ Base x rep of decimal integer y
m8=: 100"_ d2 ] Base 100 rep of decimal integer y
m9=: 0 1&#: Whole and fractional parts of y
m10=: 10 100 1000"_ #: ] Mixed base 10 ^ 1 2 3 rep of y
m11=: #. Integer from Boolean list y
m12=: <.@(10&^.)@(('.'&~: # ]) &.": % ]) Number of decimal places in y
m14=: ]&__ Negative infinity
m15=: _: Positive infinity
a16=: (&#.) (^:_1) Base x rep of decimal integer y
m17=: [: (%"1 [: ,:~ +./) ,:&1 Fraction equivalent to y