Tag: c

51 votes
24 answers
824 views
Turning off auto indent when pasting text into vim

I am making the effort to learn Vim. When I paste code into my document from the clipboard, I get extra space

avatar
Mikki
0 1 0 9
asked 07 September, 2021
62 votes
21 answers
2.3K views
How to duplicate a whole line in Vim?

How do I duplicate a whole line in Vim in a similar way to Ctrl+D in IntelliJ IDEA/ Resharper or Ctrl+Alt+↑/

avatar
Thurman
0 1 0 9
asked 07 September, 2021
57 votes
1 answers
2.8K views
Rounding BigDecimal to *always* have two decimal places

I'm trying to round BigDecimal values up, to two decimal places. I'm using BigDecimal rounded = va

avatar
Rufus
0 1 0 9
asked 07 September, 2021
53 votes
9 answers
2.8K views
Is log(n!) = Θ(n·log(n))?

I am to show that log(n!) = Θ(n·log(n)). A hint was given that I should show the upper bound with nn and sh

avatar
Santiago
0 1 0 9
asked 07 September, 2021
60 votes
11 answers
2.4K views
How can I round down a number in Javascript?

How can I round down a number in JavaScript? math.round() doesn't work because it rounds it to the neare

avatar
Rufus
0 1 0 9
asked 07 September, 2021
58 votes
10 answers
2.7K views
How can I ensure that a division of integers is always rounded up?

I want to ensure that a division of integers is always rounded up if necessary. Is there a better way than thi

avatar
Robt
0 1 0 9
asked 07 September, 2021
63 votes
6 answers
1.9K views
What is the behavior of integer division?

For example, int result; result = 125/100; or result = 43/100; Will result always be the floor of the

avatar
Hallie
0 1 0 9
asked 07 September, 2021
62 votes
8 answers
1.5K views
How to scale down a range of numbers with a known min and max value

So I am trying to figure out how to take a range of numbers and scale the values down to fit a range. The rea

avatar
Keila
0 1 0 9
asked 07 September, 2021
48 votes
19 answers
453 views
Mapping two integers to one, in a unique and deterministic way

Imagine two positive integers A and B. I want to combine these two into a single integer C. There can be no

avatar
Benton
0 1 0 9
asked 07 September, 2021
63 votes
22 answers
1.1K views
How does C compute sin() and other math functions?

I've been poring through .NET disassemblies and the GCC source code, but can't seem to find anywhere

avatar
Thurman
0 1 0 9
asked 07 September, 2021
56 votes
19 answers
644 views
The most efficient way to implement an integer based power function pow(int, int)

What is the most efficient way given to raise an integer to the power of another integer in C? // 2^3 pow(2,3

avatar
Stacia
0 1 0 9
asked 07 September, 2021
61 votes
13 answers
1.1K views
Calculating arithmetic mean (one type of average) in Python

Is there a built-in or standard library method in Python to calculate the arithmetic mean (one type of average

avatar
Juliane
0 1 0 9
asked 07 September, 2021
53 votes
23 answers
2K views
How to determine if a list of polygon points are in clockwise order?

Having a list of points, how do I find if they are in clockwise order? For example: point[0] = (5,0) point[1

avatar
Charis
0 1 0 9
asked 07 September, 2021
57 votes
11 answers
905 views
JavaScript % (modulo) gives a negative result for negative numbers

According to Google Calculator (-13) % 64 is 51. According to Javascript (see this JSBin) it is -13. How do

avatar
Percy
0 1 0 9
asked 07 September, 2021
62 votes
11 answers
1.3K views
Fast ceiling of an integer division in C / C++

Given integer values x and y, C and C++ both return as the quotient q = x/y the floor of the floating point eq

avatar
Patsy
0 1 0 9
asked 07 September, 2021
57 votes
7 answers
2.5K views
How can I divide two integers to get a double?

How do I divide two integers to get a double?

avatar
Santiago
0 1 0 9
asked 07 September, 2021
69 votes
7 answers
2.5K views
What is "entropy and information gain"?

I am reading this book (NLTK) and it is confusing. Entropy is defined as: Entropy is the sum of the proba

avatar
Leonardo
0 1 0 9
asked 07 September, 2021
66 votes
16 answers
2K views
How to round up the result of integer division?

I'm thinking in particular of how to display pagination controls, when using a language such as C# or Jav

avatar
Hilario
0 1 0 9
asked 07 September, 2021
58 votes
7 answers
1.9K views
Fastest way to determine if an integer is between two integers (inclusive) with known sets of values

Is there a faster way than x >= start && x <= end in C or C++ to test if an integer is between t

avatar
Stacia
0 1 0 9
asked 07 September, 2021
56 votes
30 answers
3K views
Calculate distance between 2 GPS coordinates

How do I calculate distance between two GPS coordinates (using latitude and longitude)?

avatar
Stacia
0 1 0 9
asked 07 September, 2021