-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.js
More file actions
49 lines (42 loc) · 1.17 KB
/
math.js
File metadata and controls
49 lines (42 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function bitString(remaining) {
let resultDivided = Math.floor(remaining / 64)
let resultModulo = remaining % 64
let returnString = ''
if (resultDivided > 0) {
returnString += resultDivided + ' * 64';
}
if (resultModulo > 0) {
returnString += ' + ' + resultModulo ;
}
return returnString
}
function add() {
let zahl= Number(document.forms[0].zahl1.value)
let ergebnis = (zahl - 15) / 2.8 + 5
let array = ergebnis.toString().split(".");
let switchZahl = 0
if (array.length > 1) {
switchZahl = Number('0.' + array[1])
}
let ausgabe = '';
console.log(switchZahl)
switch (true) {
case switchZahl == 0:
ausgabe = bitString(Number(array[0]));
document.forms[0].ergebnis2.value = ''
break
case switchZahl < 0.4:
ausgabe = bitString(Number(array[0]))
document.forms[0].ergebnis2.value = '+6'
break;
case switchZahl < 0.78:
ausgabe = bitString(Number(array[0]))
document.forms[0].ergebnis2.value = '+12'
break;
default:
ausgabe = bitString(Number(array[0]) + 1);
document.forms[0].ergebnis2.value = ''
break
}
document.forms[0].ergebnis.value = ausgabe;
}