Skip to content

Commit

Permalink
Add erlang:integer_to_binary/1 BIF
Browse files Browse the repository at this point in the history
  • Loading branch information
krestenkrab committed Aug 20, 2013
1 parent a0baf81 commit 50131f5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/erjang/m/erlang/ErlConvert.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ public static EAtom list_to_existing_atom(EObject obj) {
return EAtom.existing_atom(seq.stringValue());
}

@BIF
public static EBinary integer_to_binary(EObject arg) {
EInteger i = arg.testInteger();
if (i == null) throw ERT.badarg(arg);

byte[] bin = i.toString().getBytes(IO.ISO_LATIN_1);
return EBinary.make(bin);
}

@BIF
public static EInteger list_to_integer(EObject obj) {
EString seq;
Expand Down

0 comments on commit 50131f5

Please sign in to comment.