This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Chart = (function(window,d3) { | |
var svg, data, x, y, xAxis, yAxis, dim, chartWrapper, line, path, margin = {}, width, height, locator; | |
var breakPoint = 768; | |
d3.csv('data.csv', init); //load data, then initialize chart | |
//called once the data is loaded | |
function init(csv) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Implement a function that takes in an integer and prints out its two's complement value by following the algorithm described above. Hint: to invert the bits of a number you can use the "~" operator. For example ~25 will invert the bits of the integer 25. | |
function twosComplement(int){ | |
console.log('int to string is ' + int.toString(2)); | |
const binaryInt = int.toString(2); | |
// console.log(binaryInt.length) | |
let result = ''; | |
for (var i = 0; i < binaryInt.length; i++){ | |
if (binaryInt[i] === '1') { | |
result = result.concat('0'); |