diff --git a/src/app/backend/berechnung.ts b/src/app/backend/berechnung.ts index ed3667a..9c9e476 100644 --- a/src/app/backend/berechnung.ts +++ b/src/app/backend/berechnung.ts @@ -15,18 +15,18 @@ export class Berechnung { } this.binArr.push(tmp); }); - return this.binArr.join(".") + return this.binArr.join(" ") } binToDec(bin: string) { var arr = bin.split(" ") alert(arr) let binNum = "" - for (let index = 0; index < arr.length; index++) { - binNum += parseInt(arr[index], 2).toString(); + for (let index = 0; index < arr.length - 1; index++) { + binNum += parseInt(arr[index], 2).toString() + "."; } - return binNum; + return binNum.slice(0, -1); } @@ -36,7 +36,7 @@ export class Berechnung { } broadCastBin(binIp: string, prefix: number) { - var arr = binIp.split('.'); + var arr = binIp.split(' '); let prefixIp = arr.join(""); let hostbin = prefixIp.slice(0, prefix); hostbin = hostbin + "1".repeat(32 - prefix);