Broadcast ready

This commit is contained in:
marcusferl@weifer.de 2022-08-31 14:25:53 +02:00
parent dc5af6085e
commit 49569a33d5

View File

@ -15,18 +15,18 @@ export class Berechnung {
} }
this.binArr.push(tmp); this.binArr.push(tmp);
}); });
return this.binArr.join(".") return this.binArr.join(" ")
} }
binToDec(bin: string) { binToDec(bin: string) {
var arr = bin.split(" ") var arr = bin.split(" ")
alert(arr) alert(arr)
let binNum = "" let binNum = ""
for (let index = 0; index < arr.length; index++) { for (let index = 0; index < arr.length - 1; index++) {
binNum += parseInt(arr[index], 2).toString(); 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) { broadCastBin(binIp: string, prefix: number) {
var arr = binIp.split('.'); var arr = binIp.split(' ');
let prefixIp = arr.join(""); let prefixIp = arr.join("");
let hostbin = prefixIp.slice(0, prefix); let hostbin = prefixIp.slice(0, prefix);
hostbin = hostbin + "1".repeat(32 - prefix); hostbin = hostbin + "1".repeat(32 - prefix);