473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

"Arrange all" calculation

Someone knows "Arrange All" windows calculation formula used in MDI?
Nov 15 '05 #1
5 1561
Solved it:
For all who want to know:
double sqrt = Math.Sqrt((double)numb);

int floor = (int)Math.Round(Math.Floor(sqrt));

int ceil = (int)Math.Round(Math.Ceiling(sqrt));

int[]rows = new int[floor];

int i;

for(i=0;i<floor;i++)

rows[i]=ceil;

int diff = numb-floor*ceil;

if(diff > 0)

{

for(i=floor-1;diff-- > 0 && i>=0;i--)

{

rows[i]++;

}

}

else if(diff <0)

{

for(i=0;diff++ < 0 && i<floor;i++)

{

rows[i]--;

}

}

That'a all folks :)
"Tamir Khason" <ta**********@tcon-NOSPAM.co.il> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
Someone knows "Arrange All" windows calculation formula used in MDI?

Nov 15 '05 #2
Tamir Khason <ta**********@tcon-NOSPAM.co.il> wrote:
Solved it:
For all who want to know:
double sqrt = Math.Sqrt((double)numb);

int floor = (int)Math.Round(Math.Floor(sqrt));

int ceil = (int)Math.Round(Math.Ceiling(sqrt));


Out of interest, why are you calling Math.Round here? Math.Floor and
Math.Ceiling already return whole numbers, so Math.Round shouldn't make
any odds.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #3
Good point, I was in Java :) (there it's real double... I think in c++
too...)

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Tamir Khason <ta**********@tcon-NOSPAM.co.il> wrote:
Solved it:
For all who want to know:
double sqrt = Math.Sqrt((double)numb);

int floor = (int)Math.Round(Math.Floor(sqrt));

int ceil = (int)Math.Round(Math.Ceiling(sqrt));


Out of interest, why are you calling Math.Round here? Math.Floor and
Math.Ceiling already return whole numbers, so Math.Round shouldn't make
any odds.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #4
Tamir Khason <ta**********@tcon-NOSPAM.co.il> wrote:
Good point, I was in Java :) (there it's real double... I think in c++
too...)


What exactly do you mean? In Java Math.floor and Math.ceil still return
whole numbers - as doubles, so you'd still need to cast to int, but
even so, you still don't need the extra call.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5

Hi Tamir,

Yes, in C#, Math.Floor will return an already casted double value, so there
is no need to call Math.Round. :-)

Anyway, this is a little case, which does not matter.

If you have any further question, please feel free to post, I will help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following...
3
by: Adam Toline | last post by:
In reference to the following: http://www.bellecose.com/form.htm At the top of each column there is a box for "All". When one is checked I need to check all of (and only) those boxes...
4
by: meganrobertson22 | last post by:
Hi Everyone- I have a question about how to add and then use the "All" selection in a combo box. I am trying to figure out how to: (1) add "All" as a selection to a combo box and then (2)...
3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
2
by: Murphy | last post by:
Our website contains subdirectories for each subsidiary company, each company has it's own look and feel to the pages in their subdirectory although they are all part of the main website. The...
4
by: google | last post by:
Hi Hope someone can help me with this - have been staring at this problem all day, and with the cold I've got, just don't seem to be able to figure it out! I've got two tables, here with some...
2
by: bhdvir | last post by:
Does anybody have any advice on selecting all records within a iif-statement? I have a form in which one has to state if all projects or just a selection of projects are to be used for a query....
2
by: getmeidea | last post by:
Hi all, String x = "\\"; This string will have the value \. Now for any string contains \, i need to replace with \\. But when i use x = x.replaceAll("\\", "\\\\"); I am getting runtime...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.