math

Convert Sign-Bit, Exponent and Mantissa to float?

孤街浪徒 提交于 2021-01-04 05:55:17
问题 I have the Sign Bit, Exponent and Mantissa (as shown in the code below). I'm trying to take this value and turn it into the float. The goal of this is to get 59.98 (it'll read as 59.9799995 ) uint32_t FullBinaryValue = (Converted[0] << 24) | (Converted[1] << 16) | (Converted[2] << 8) | (Converted[3]); unsigned int sign_bit = (FullBinaryValue & 0x80000000); unsigned int exponent = (FullBinaryValue & 0x7F800000) >> 23; unsigned int mantissa = (FullBinaryValue & 0x7FFFFF); What I originally

CNF by truth table [closed]

霸气de小男生 提交于 2021-01-04 05:33:31
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 months ago . Improve this question I have a boolean function that is presented by truth table. In total it is 10 variables and I'd like to get CNF with a reasonable length (not necessary the shortest, but short enough). How can I do it? Python script or any public available software such as

CNF by truth table [closed]

你离开我真会死。 提交于 2021-01-04 05:32:46
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 months ago . Improve this question I have a boolean function that is presented by truth table. In total it is 10 variables and I'd like to get CNF with a reasonable length (not necessary the shortest, but short enough). How can I do it? Python script or any public available software such as

NSDecimalNumber to the power of NSDecimalNumber

本秂侑毒 提交于 2021-01-03 05:35:14
问题 I have two NSDecimalNumbers and I need to apply one to the power of the other, originally this code was using doubles and I could compute this with the pow() function like this: double result = pow(value1, value2); The problem I have is I am converting the code to use NSDecimalNumbers and although they include the method toThePowerOf, it only accepts int values. At the moment the only solution I have to this problem is to convert the NSDecimalNumbers Temporarily but this results in a loss of

How to call a julia method defined in an imported package from c++?

两盒软妹~` 提交于 2021-01-02 06:51:19
问题 I need a c++ library to compute the polygamma function for complex arguments. After some googling that brought me to this https://scicomp.stackexchange.com/questions/23194/i-am-searching-for-c-code-of-the-complex-polygamma-function/23195/ I decided to try to call the julia library from c++. In order to embedd julia in c++ I followed the example at julia-lang embedding into c. where julia is used to calculate the sqrt(2) . This works fine... how can I generalize the example to work for my case

How to refine the result of a floating point division result?

﹥>﹥吖頭↗ 提交于 2021-01-02 04:00:43
问题 I have an an algorithm for calculating the floating point square root divide using the newton-raphson algorith. My results are not fully accurate and sometimes off by 1 ulp. I was wondering if there is a refinement algorithm for floating point division to get the final bits of accuracy. I use the tuckerman test for square root, but is there a similar algorithm for division? Or can the tuckerman test be adapted for division? I tried using this algorithm too but didn't get full accuracy results

How to refine the result of a floating point division result?

自作多情 提交于 2021-01-02 03:59:36
问题 I have an an algorithm for calculating the floating point square root divide using the newton-raphson algorith. My results are not fully accurate and sometimes off by 1 ulp. I was wondering if there is a refinement algorithm for floating point division to get the final bits of accuracy. I use the tuckerman test for square root, but is there a similar algorithm for division? Or can the tuckerman test be adapted for division? I tried using this algorithm too but didn't get full accuracy results

Fastest way of testing if a number is prime with Python [duplicate]

心已入冬 提交于 2021-01-01 13:29:26
问题 This question already has answers here : Fast prime factorization module (7 answers) Closed 3 years ago . I'm trying to get a fast way to determine if a number is prime using Python. I have two functions to do this. Both return either True or False. Function isPrime1 is very fast to return False is a number is not a prime. For example with a big number. But it is slow in testing True for big prime numbers. Function isPrime2 is faster in returning True for prime numbers. But if a number is big

Fastest way of testing if a number is prime with Python [duplicate]

孤街醉人 提交于 2021-01-01 13:27:43
问题 This question already has answers here : Fast prime factorization module (7 answers) Closed 3 years ago . I'm trying to get a fast way to determine if a number is prime using Python. I have two functions to do this. Both return either True or False. Function isPrime1 is very fast to return False is a number is not a prime. For example with a big number. But it is slow in testing True for big prime numbers. Function isPrime2 is faster in returning True for prime numbers. But if a number is big

How to remove frequency from signal

倖福魔咒の 提交于 2020-12-30 14:34:25
问题 I want to remove one frequency (one peak) from signal and plot my function without it. After fft I found frequency and amplitude and I am not sure what I need to do now. For example I want to remove my highest peak (marked with red dot on plot). import numpy as np import matplotlib.pyplot as plt # create data N = 4097 T = 100.0 t = np.linspace(-T/2,T/2,N) f = np.sin(50.0 * 2.0*np.pi*t) + 0.5*np.sin(80.0 * 2.0*np.pi*t) #plot function plt.plot(t,f,'r') plt.show() # perform FT and multiply by dt