Questions tagged [divide]

Separate or be separated into parts

Separate or be separated into parts

688 questions
5
votes
3 answers

Divide by 3 and Round up (If need be) C#

I have come to a point in my game where I have to implement a feature which divides a number by 3 and makes it a whole integer. i.e. not 3.5 or 2.6 etc.... It was to be a whole number, like 3, or 5. Does anyone know how I can do this?
Subby
  • 5,370
  • 15
  • 70
  • 125
4
votes
4 answers

How to randomly split data into three equal sizes?

I have a dataset with 9558 rows from three different projects. I want to randomly split this dataset in three equal groups and assign a unique ID for each group, so that Project1_Project_2_Project3 becomes Project1, Project2 and Project3. I have…
4
votes
3 answers

How to convert continuous values into discrete values by equivalent partitioning in pandas

I want to transform continuous values of a dataframe column into discrete values by equivalent partioning. For example, the following is my input. I want to divide the continuous value in column a into 3 intervals. Input: import pandas as pd import…
rosefun
  • 1,797
  • 1
  • 21
  • 33
4
votes
1 answer

Creating line dividers in Android tab layout paragraphs

Hey all, first post and a noob in Android programming, but willing to learn! Basically I've taken the Google sample of a tab layout from here I found that method to be very easy to create tabs with text within each tab, but I'm trying to make it so…
Clozecall
  • 101
  • 1
  • 2
  • 9
4
votes
3 answers

Add / Divide Numbers in PHP

I am working on a Facebook App that needs to be able to average three numbers. But, it always return 0 as the answer. Here is my code: $y = 100; $n = 250; $m = 300; $number = ($y + $n + $m / 3); echo 'Index: '.$number; It always displays Index:…
Zac Brown
  • 5,905
  • 19
  • 59
  • 107
4
votes
4 answers

Constant Divide Not Optimized?

I have the following line of code: #define A 360 #define B 360 temp = (s16_myvar * A) / B; My compiler (Windriver DIAB PPC in this case, using standard extended optimization settings -XO) does not seem to optimize this away to something like temp…
MAF
  • 59
  • 3
4
votes
3 answers

Will the result be implementation-defined if one or two of the operands of the / or % operator are negative numbers?

e.g. What are the values of these expressions? Do they depend on the compiler? -7/3 -7%3 7/-3 7%-3 -7/-3 -7%-3
xiaokaoy
  • 1,608
  • 3
  • 15
  • 27
4
votes
2 answers

How to implement relational equivalent of the DIVIDE operation in SQL Server

I was reading relational algebra from one of the textbook. I came across DIVIDE operation. From Wikipedia: The division is a binary operation that is written as R ÷ S. The result consists of the restrictions of tuples in R to the attribute names…
Mahesha999
  • 22,693
  • 29
  • 116
  • 189
4
votes
2 answers

PIG: sum and division, creating an object

I am writing a pig program that loads a file that separates its entires with tabs ex: name TAB year TAB count TAB... file = LOAD 'file.csv' USING PigStorage('\t') as (type: chararray, year: chararray, match_count: float, volume_count: float); --…
user3295674
  • 893
  • 5
  • 19
  • 42
4
votes
2 answers

ASM/Delphi - Divide

I am trying to divide two numbers 50 and 5. This is my code: function Divide(Num1, Num2: Integer): Integer; asm MOV EAX, Num1 CDQ MOV ECX, Num2 IDIV ECX MOV @RESULT, ECX end; It gives me a DivisionByZeroException exception in…
nexno
  • 429
  • 8
  • 26
4
votes
3 answers

Dividing all the numbers in a data frame by a chosen row in the same data frame and corresponding column position in R

I have a data frame x1 which I generated with this code, x <- c(1:10) y <- x^3 z <- y-20 s <- z/3 t <- s*6 q <- s*y x1 <- cbind(x,y,z,s,t,q) x1 <- data.frame(x1) x y z s t q 1 1 1 -19 -6.333333 -38 …
Amm
  • 1,749
  • 4
  • 17
  • 27
4
votes
2 answers

divide div with percentage

Simple question I want to divide a div in to two columns I am using to divs with http://jsfiddle.net/petran/WnKW3/ display:inline-block and it works fine , when I add widths with sum of 100% the second column appears underneath seems that it…
Petran
  • 7,677
  • 22
  • 65
  • 104
3
votes
3 answers

How do I divide without remainder, if I take random integers?

I am still a new at programming. I wanted to programm a full script where i can decide by the operators and get 2 random number and so on. It worked but if I wanna devide something there are some calculations like 59:6= with like 9 digits after…
Philip
  • 33
  • 5
3
votes
2 answers

Dividing each row by the previous one in R

I have R dataframe: city hour value 0 NY 0 12 1 NY 12 24 2 LA 0 3 3 LA 12 9 I want, for each city, to divide each row by the previous one and write the result into a new dataframe. The desired output is: city ratio NY 2 LA …
LIppek
  • 35
  • 6
3
votes
3 answers

How to divide rows in new column by first / previous row?

I would like to create two columns: That the value from the next row should be divided by the value in the first row. In order for the value from the next row to be divided by the value from the previous line and expressed as a percentage. Data No…
Peter
  • 29
  • 4