JavaScript by Crowder T. J.;

JavaScript by Crowder T. J.;

Author:Crowder, T. J.; [Crowder, T.J.]
Language: eng
Format: epub
Publisher: John Wiley & Sons, Incorporated
Published: 2020-01-22T00:00:00+00:00


How did -25.4 become 231?!

The first parts are easy: -25.4 is already a number so you don't have to convert it to one, and when you truncate it toward zero, you get –25. Now it's time for that modulo operation (see the inset earlier). One way to compute that modulo is the following code snippet, where value is the value ( —25) and max is 2n ( 28, which is 256, in this 8-bit example):

const value = -25; const max = 256; const negative = value < 0; const remainder = Math.abs(value) % max; const result = negative ? max - remainder : remainder;



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.