exponent

How to convert a string containing an exponential number to decimal and back to string

妖精的绣舞 提交于 2019-12-07 12:12:30
问题 I'm converting code between delphi and c#. Values are stored as strings in a text file from the delphi app. An example of the stored value is : '4.42615029219009E-5' Now in my c# app I need to read in that string value and then later have the capability to write out the value again. Initially I used code similar to: string stringField = "4.42615029219009E-5"; double someMoneyVar = Convert.ToDouble(stringField) later if I need to recreate the text file with the value of someMoneyVar then using

What is the structure of the public key of a signed assembly in C#?

你说的曾经没有我的故事 提交于 2019-12-06 13:51:48
问题 Using this code to retrieve the public key bytes... var pubKey = AppDomain.CurrentDomain.DomainManager.EntryAssembly .GetName().GetPublicKey(); What is this common structure at the start (first 32 bytes) of the key? It's not ASN.1 and it might not be variable. I can google it and get repeats. // 00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 Is it all reversed or just part of it (e.g. the modulus at the end)? 52 53 41 31 is a string of RSA1 . My key's modulus is 1024

Calculate exponents via addition only

老子叫甜甜 提交于 2019-12-06 09:50:48
问题 We're writing a very simple program to execute on a processor we've built for a class. It doesn't have the capability to multiply or divide. We do however, had support for addition, subtraction, and, or, and branching for loop control (like branch on equal if you are familiar with MIPS). We were thinking a neat program to run on it would be some sort of x^n program. Of course, those numbers would have to be hardcoded, but given the limitations of our processor, is it realistic? Is there an

Generate RSA Public key from modulus and exponent in bytes in Objective-c

血红的双手。 提交于 2019-12-06 02:26:21
I'd searching many websites trying to understand how does RSA works. I have a modulus "A89F25A56FA6DA258C8CA8B40427D927B4A1EB4D7EA326BBB12F97DED70AE5E4480FC9C5E8A972177110A1CC318D06D2F8F5C4844AC5FA79A4DC470BB11ED635699C17081B90F1B984F12E92C1C529276D8AF8EC7F28492097D8CD5BECEA16FE4088F6CFAB4A1B42328A1B996F9278B0B7E3311CA5EF856C2F888474B83612A82E4E00D0CD4069A6783140433D50725F" and exponent "03" and i have to decrypt information formated in hex bytes. My questions are: How do i create a public key? Once i have the public key do i have to encode in base64 or the public key is ready to decrypt?

Matrix power sum

两盒软妹~` 提交于 2019-12-06 01:57:13
问题 What is the best way to calculate sum of matrices such as A^i + A^(i+1) + A^i+2........A^n for very large n? I have thought of two possible ways: 1) Use logarithmic matrix exponentiation(LME) for A^i, then calculate the subsequent matrices by multiplying by A. Problem : Doesn't really take advantage of the LME algorithm as i am using it only for the lowest power!! 2)Use LME for finding A^n and memoize the intermediate calculations. Problem: Too much space required for large n. Is there a

How to convert a string containing an exponential number to decimal and back to string

左心房为你撑大大i 提交于 2019-12-05 20:49:28
I'm converting code between delphi and c#. Values are stored as strings in a text file from the delphi app. An example of the stored value is : '4.42615029219009E-5' Now in my c# app I need to read in that string value and then later have the capability to write out the value again. Initially I used code similar to: string stringField = "4.42615029219009E-5"; double someMoneyVar = Convert.ToDouble(stringField) later if I need to recreate the text file with the value of someMoneyVar then using a simple: string.Format("{0}", someMoneyVar) would output: 4.42615029219009E-05 // note the 0 Lastly,

Calculating powers (e.g. 2^11) quickly [duplicate]

♀尐吖头ヾ 提交于 2019-12-05 03:09:42
Possible Duplicate: The most efficient way to implement an integer based power function pow(int, int) How can I calculate powers with better runtime? E.g. 2^13. I remember seeing somewhere that it has something to do with the following calculation: 2^13 = 2^8 * 2^4 * 2^1 But I can't see how calculating each component of the right side of the equation and then multiplying them would help me. Any ideas? Edit: I did mean with any base. How do the algorithms you've mentioned below, in particular the "Exponentation by squaring", improve the runtime / complexity? Omnifarious There is a generalized

What is the structure of the public key of a signed assembly in C#?

时光总嘲笑我的痴心妄想 提交于 2019-12-04 18:35:05
Using this code to retrieve the public key bytes... var pubKey = AppDomain.CurrentDomain.DomainManager.EntryAssembly .GetName().GetPublicKey(); What is this common structure at the start (first 32 bytes) of the key? It's not ASN.1 and it might not be variable. I can google it and get repeats. // 00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 Is it all reversed or just part of it (e.g. the modulus at the end)? 52 53 41 31 is a string of RSA1 . My key's modulus is 1024 bit, so I was looking for something that described the length. 0x0400 ( 00 04 B.E.) would be 1024 (bits

Matrix power sum

安稳与你 提交于 2019-12-04 05:23:47
What is the best way to calculate sum of matrices such as A^i + A^(i+1) + A^i+2........A^n for very large n? I have thought of two possible ways: 1) Use logarithmic matrix exponentiation(LME) for A^i, then calculate the subsequent matrices by multiplying by A. Problem : Doesn't really take advantage of the LME algorithm as i am using it only for the lowest power!! 2)Use LME for finding A^n and memoize the intermediate calculations. Problem: Too much space required for large n. Is there a third way? Notice that: A + A^2 = A(I + A) A + A^2 + A^3 = A(I + A) + A^3 A + A^2 + A^3 + A^4 = (A + A^2)(I

To Find Large Powers in C++ [duplicate]

蓝咒 提交于 2019-12-03 21:29:40
This question already has an answer here: How to calculate modulus of large numbers? 10 answers I have two numbers A and B where A and B can be in the range 1<= A,B <=100^100000 How can we find the value of A^B modulo some M in C++ ?? Floris In the duplicate I pointed out, the solution I particularly like is https://stackoverflow.com/a/8972838/1967396 (see there for attribution and references) For your convenience I reproduce the code here (wrapped into an SCCE - but using C, not C++): #include <stdio.h> int modular(int base, unsigned int exp, unsigned int mod) { int x = 1; int i; int power =