I need to add Column1 + Column2 And Display Result In Column3 But I need to do it for all rows in column3 automatically. I need a very short code. Thankyou. |
+0 forum
2 | ||

Hello, I wrote a library for arbitrary precision arithmetic recently and spent a long time implementing efficient multiplication algorithms. Now I am looking to see if it is possible for me to optimize anywhere else. One place that I thought should be more optimizeable is my division algorithm. Right now I use (hiding some internal implementation stuff): Int divide(Int numerator, Int denominator)const { if (denominator==0) return DIVIDE_BY_ZERO_ERROR; if (numerator==0) return 0; if (numerator.sign()!=denominator.sign())//result is negative return -((-numerator)/denominator); if (numerator==denominator) return 1; Int num=numerator.abs(); Int den=denominator.abs(); Int ret=0; while (num>den) { ret++; num-=den; } return ret; } Which is fairly slow, … |
+0 forum
7 | ||

Hello, I am working on an arbitrary precision arithmetic library. I already created a version that just stored numbers as "before decimal point [unsigned array]" and "after decimal point [unsigned array]". The issue is that it is both inefficient and incomplete. I would like to incorporate complex numbers into the system (I am not, however going to incorporate quartic numbers). I am also going to incorporate vectors and matrices. My issue is that I cannot decide how to store complex numbers and (maybe?) vectors. I realize that the optimal approach would probably be to store it as either standard representation … |
+0 forum
4 | ||

Hi, I'm using this SQL statement to retrieve Value and Date which will then be plotted on a graph: SELECT DISTINCT assets.SEDOL,assets.Quantity,stock_names.value,stock_names.Fileid,date_header.dateid FROM assets,stock_names,date_header WHERE assets.Client_ref = '$clientref' AND stock_names.SEDOL = assets.SEDOL AND date_header.fileid = stock_names.fileid I'm also selecting Quantity. Instead of having to multiply out the arrays, how can I multiply value and quantity inside the SQL statement and then just return Value (multiplied by quantity)? |
+0 forum
2 | ||

I'm about at my wits' end trying to figure this out. This is homework, so any hints would be appreciated. I was tasked with filling in a few blocks of code (these are denoted by comment lines with a number resting in the middle) involving function calls in MIPS. The program is supposed to read a specified number of integers (determined at run time by the first question), re-print them, then flip the order and print them again. It then asks if there is another case to enter, and exits following a negative response. Specifically, the error in question is … |
+0 forum
5 | ||

Hi guys. I am having issues with the output of this program. Can somebody tell me what I have to do to make this work correctly? Here is the code I have so far: import java.util.Scanner; //text scanner to parse primitive types and strings using regular expressions. public class Operations { private static Object total; @SuppressWarnings("resource") public static void main(String[] args) { Scanner input=new Scanner (System.in); int num1=0, num2=0; System.out.printf("Enter First Number:\t "); num1=input.nextInt(); System.out.printf("Enter Second Number:\t "); num2=input.nextInt(); System.out.println(""); System.out.format("%1s%25s","Operation","Result\n"); String fmt = "%-28s %-7d \n"; String solution1= Integer.toString(num1) + "+" + Integer.toString(num2); System.out.printf(fmt, solution1, total); String format1 = … |
-2 forum
6 | ||

Hey there, I'm having issues with a custom string tokenizer I'm using for an assignment. I've looked around and haven't managed to find anything that really answers my question, so here goes nothing. Whenever I run the program and it runs the tokenizer, I get a seg fault. I'm fairly new to pointer arithmetic, so if someone could push me in the right direction, that would be great. Here is the offending function and main function: char** tokenize(char* str, char ch, char** arr){ while(*str != '\0'){ /*While we have not reached the end of the string*/ if(*str == ch){ str++; … |
+0 forum
9 | ||

I am working to take c code from an academic paper and edit. I am studying cryptographic algorithms. I have ran the following code, but I am having a little difficulty understanding two things. First, the program uses unsigned long ints. When they are added or subtracted, I don't get the values I would expect. For example: P, Q, My sum by hand, sum using c 01100011010100011110000110110111 10111001011110010011011110011110 00011100110010110001100101010101 00011100110010110001100[COLOR="Red"]0[/COLOR]010101[COLOR="Red"]10[/COLOR] I understand that unsigned long int is 32 bit and that the addition is mod 2^32, but I thought the last carry bit when you add to the left by … |
+0 forum
4 | ||

From what I understand, ALU is exclusively for mathematical operations. For simple tasks like reading a web page, saving a text file, copying data etc., are arithmetic operations used or can the processor do it without using that? I don't have much knowledge about computer architecture, but it seems to me that these jobs mainly deal with control instructions and no arithmetic is required, apart from maybe ASCII conversions. |
+0 forum
1 | ||

So I'm trying to achieve this myself, but I decided to ask on this forum to see if anyone knew about some obscure project on sourceforge or something that did exactly this: I need to store very large numbers and perform arithmetic on them. I am storing the values in a string of characters. The reason I am not using a bigint library is not only do I need something a little more tailored to my needs (I'm reading a binary file into an array of chars since I cant read it into any other variable, ifstream::read() ) I can't … |
+0 forum
1 | ||

Hey, I have a set of types which are all arithmetic (have operators for addition, subtraction, multiplication, etc.). I want to aggregate any number of them into a single object, so I'm using the std::tuple class template and the <tuple> library (and Boost.Tuple for backward compatibility). My question is a bit of a shot in the dark: Has anyone heard or seen a tuple-like class template that implements all the arithmetic operators? For example, the std::tuple and boost::tuple classes both implement all the comparison operators which will only compile correctly if all the types contained in the tuple also have … |
+0 forum
4 | ||

I am having trouble with making my program read in binary and convert it into an integer so that I can do arithmetic on it, and then output it back out as binary. Here is my code. The first part of it works, and I can read in the 2 binary numbers, but when I have a problem with the segment that converts it into an integer. [CODE]#include <stdio.h> #include <string.h> int main() { int i, num1, num2, num3=0; unsigned choice, string; char str1[7], op, str2[8], str4[8]; int str3[8]={64,32,16,8,4,2,1}; do { system("clear"); printf("Enter an Operation?\n"); printf("Yes(1) or No(2)\n"); scanf("%u", &choice); … |
+0 forum
5 | ||

I have a program assignment in my C and Unix class that allows the user to enter two numbers in binary seperated by (*,+,-,or /). It then has to produce an answer and loop back to the beginning. It also has to have an option to exit. Can anyone help? |
+0 forum
17 | ||

Dear All, I’m implementing a vector class that allows me to do vector arithmetic. What I’ve implemented is the following: [CODE]class mVec { private: float vec[3]; public: mVec(); mVec(const float * const parray); mVec(const float a, const float b, const float c); ~mVec(); mVec operator+(const mVec& param); mVec operator-(const mVec& param); //other operators... float* useAsArray() { return vec; } };[/CODE] As I have already created many functions that work with arrays of three floats, I would like to make my class mVec also compatible with them, without having to overload all these functions. What apparently works is the member function … |
+0 forum
2 | ||

Hey there, I'm having trouble creating a multiplication function for the program as I have two classes to keep in mind (Monomial and Polynomial). And if possible, a little advice on how to make my for statements in the arithmetic operators more flexible to user input such as i<PolynomialSize, which I just can't seem to find a way around it. So any help or hints would be helpful. My functions work partially, by the way. Here's what I got so far: [CODE]/*-- Polynomial.h --------------------------------------------------------- Defines the monomial and polynomial classes. Polynomial is implemented basically as a list of monomials. ---------------------------------------------------------------------------*/ … |
+0 forum
2 | ||

Hi guys!! I've to make a program that reads an arithmetical sentence from a textbox, e.g 12.3*34+4*5-3 and then on another textbox identify and display what is the content of the first textbox, for example taking the last ex: If I have this input: 12.3*34+4*5-3 The output should look like this: <number>12.3 <operator> * <number> 34 <operator> + <number> 4 <operator> * <number> 5 <operator> - <number> 3 This program should only read this operators like (+,-,*,/). I'm have in mind 2 ways of doing it, one with regex and the other taking the first sentence, put it on an … |
+0 forum
3 |

The End.