Sign in to follow this  
Followers 0
ChrisL

Maths question

5 posts in this topic

A CD can hold upto 200 images

I need to know what formula to use to work out the quantity of CD's

If $images = 0 then there would be 0 CD

If $images = 12 then there would be 1 CD

If $images =201 then there would be 2 CD's

I have this

$images = 12
$maxCD = 200
Msgbox(0,"",Int($images/$maxCD +1))

Which works fine except for $images = 0 because you still get 1 cd.

Am I better changing the code so that if $images = 0 then $CD = 0 or is there a better way

$images = 12
$maxCD = 200

If $images >  0 then 

       $CD = Int($images/$maxCD +1)
    Else
    $CD = 0
EndIf

Just need someone to confirm I'm right or an Arse

(Note If replying Arse then the reply must be justified :) )

Share this post


Link to post
Share on other sites



That was fun...

$maxCD = 200
While 1
    $images = InputBox("CD Count", "How many images?")
    If @error Then Exit

    $CDs = Int($images / $maxCD)
    If Mod($images, $maxCD) Then $CDs += 1
    MsgBox(64, "Results", "At " & $maxCD & " images per CD, it will take " & $CDs & " CDs to hold " & $images & " images.")
WEnd

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Take a look at the Ceiling function :)

Edit: well if you're give him code i'll do it too ;)

$images = 12
$maxCD = 200
Msgbox(0,"",Ceiling($images/$maxCD))
Edited by the_lord_mephy

My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]

Share this post


Link to post
Share on other sites

Take a look at the Ceiling function ;)

Edit: well if you're give him code i'll do it too ;)

$images = 12
$maxCD = 200
Msgbox(0,"",Ceiling($images/$maxCD))
Ooh... I like! Never noticed that function before and had to go look it up!

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0