Is there an equation for this?

virtala

New member
Joined
Jun 10, 2009
Messages
4
What I'm looking for is rather simple, but yet I couldn't come up with a solution.

I need an equation which divides numbers into groups. Numbers [1,10] should give the result 1, numbers [11,20] should give the result 2, numbers [21,30] should give the result 3, and so on. If, else, when and rounding up or down are out of the question, so it will have to be a simple formula.

Can this be done? I vaguely remeber doing something like this in school, but I could be wrong.

Please help!
Laura
 
virtala said:
What I'm looking for is rather simple, but yet I couldn't come up with a solution.

I need an equation which divides numbers into groups. Numbers [1,10] should give the result 1, numbers [11,20] should give the result 2, numbers [21,30] should give the result 3, and so on. If, else, when and rounding up or down are out of the question, so it will have to be a simple formula.

Can this be done? I vaguely remeber doing something like this in school, but I could be wrong.

Please help!
Laura

Where are you using these?

There are many ways to achieve these - for example using DIV oprerator or INT(eger) operator - you would need to explain what is available to you.
 
Unfortunately my choises here are rather limited. I can use the following:
* / % + -
and functions:
sin(x) cos(x) tan(x) asin(x) acos(x) atan(x) exp(x) ln(x) log(x) sqrt(x) abs(x) rand()

But that's it. The functions are of no use and so it comes down to a simple case of adding and multiplying etc.

Is there still hope for me?
Laura
 
Are you restricted to integers in this fairly odd system? For example, what is 12/10? Is it 1.2, or just 1?

Why are you restricted as you indicate?
 
I kind of wish I were restricted to integers, since that way my problem would be solved. So yes, 10/12 is still 1.2.

As to the why, it's this wonderful system I'm working with, which uses pre-made function blocks and only the functions which I listed are available. In homework terms the problem goes like this:
"Laura has 100 boxes which she has labled each with a consecutive number from 1...100. The boxes are to be shipped in crates, which can contain 10 boxes each. The boxes have to be packed in order i.e. crate 1 should have boxes 1..10 etc. Please write out a formula which tells Laura which crate each box belogs to, so she can label them correctly."

And no, this isn't homework :wink:
Laura
 
virtala said:
I need an equation which divides numbers into groups.
Numbers [1,10] should give the result 1, numbers [11,20] should give the result 2, ...

If not restricted to integers, then these should be: [0, <11] , [11, <21] ...or something similar.
As is, where does (as example) 10.5 fall ?
 
There may be more functionality than you admit.

If we PRINT 1.2, will we get the integer value? What print formats are available?

1) Subtract 5
2) Divide by 10
3) Add 0.999999999
4) Print with Integer Format if it rounds 5/4.
 
Sorry, I might have misundersood your qyestion.
My inputs are of course integers, so only numbers 1, 2, 3, 4, 5, 6 and so on are the ones I need to deal with.
The problem is that I would like to have my answers in integers as well...

In excel I would use a formula like this one ROUNDUP(X/10;0) where X represents my input numbers. But no, this sort of thing is not available (trust me on this) and I need to get rid of the decimals in some other way.
 
Make your ranges 0-9, 10-19, ......
and add 1 to result ... get my drift?
 
Read N

If N.GT.0 AND N.LE.9 M=0 and STOP

If N.LE.19 M=1 and STOP

If N.LE.29 M=2 and STOP

Howfar do you want to go?
 
That ain't no equation Subhotosh : go to your room without dessert!

...and THE equation is: g = INT[(n - 1) / 10) + 1 ; where's my little red star?
 
But she can't use INT or DIV or Floor or Celing function...... Not allowed

Now you have to go to the corner...
 
This looks like a job for....

~ ~ ~ ~ ~ Discrete Fourier Transform Man!! ~ ~ ~ ~ ~

find some coefficients a[sub:gpi0xhua]0[/sub:gpi0xhua],...a[sub:gpi0xhua]5[/sub:gpi0xhua], b[sub:gpi0xhua]1[/sub:gpi0xhua],...b[sub:gpi0xhua]5[/sub:gpi0xhua], so that

f(x) = a[sub:gpi0xhua]0[/sub:gpi0xhua] + a[sub:gpi0xhua]1[/sub:gpi0xhua]cos(1*x*pi/5) + b[sub:gpi0xhua]1[/sub:gpi0xhua]sin(1*x*pi/5) + .. + a[sub:gpi0xhua]5[/sub:gpi0xhua]cos(5*x*pi/5) + b[sub:gpi0xhua]5[/sub:gpi0xhua]sin(5*x*pi/5) = -x/10 for x=0,1,2,3,4,5,6,7,8,9,

then your answer is x/10 + f(x)
 
Mike, if whatever is being used does not handle simplicities like FLOOR and CEILING,
I doubt it'll handle SIN and the likes...

Virtala tells us:
> In excel I would use a formula like this one ROUNDUP(X/10;0) where X represents my input numbers. But no,
> this sort of thing is not available (trust me on this) and I need to get rid of the decimals in some other way.

BUT does not tell us WHAT IS available...I guess we're suppose to guess :shock:
So we can "guess" and answer: buy an eraser :wink:
 
Denis said:
Mike, if whatever is being used does not handle simplicities like FLOOR and CEILING,
I doubt it'll handle SIN and the likes... Actually s/he does!!
Unfortunately my choises here are rather limited. I can use the following:
* / % + -
and functions:
sin(x) cos(x) tan(x) asin(x) acos(x) atan(x) exp(x) ln(x) log(x) sqrt(x) abs(x) rand()
Virtala tells us:
> In excel I would use a formula like this one ROUNDUP(X/10;0) where X represents my input numbers. But no,
> this sort of thing is not available (trust me on this) and I need to get rid of the decimals in some other way.

BUT does not tell us WHAT IS available...I guess we're suppose to guess :shock:
So we can "guess" and answer: buy an eraser :wink:
 
I must be blind...isn't % used to declare integers? If so.....
 
FORTRAN used have the handy method - any variable named begining with I, J, K, L, M & N were declared integer by defaiult (created lot of headache too for beginners).
 
Denis said:
I must be blind...

That's what happens - running after loose pucks on blinding ice...

isn't % used to declare integers? If so.....
 
Subhotosh Khan said:
That's what happens - running after loose pucks on blinding ice...
Ahhhh...I see you read my little hockey thingie :wink:
 
Isn't it as simple as:

f(x) = [x - (x % 10)]/10

Of course, % is "mod" in C++. I'm not sure here.
 
Top