Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Destory  
#1 Posted : 23 May 2017 21:40:33(UTC)
Destory

Rank: Newbie

Groups: Registered
Joined: 23/05/2017(UTC)
Posts: 1
United States
Location: Texas

Thanks for all the work you have put into this software!

I was wondering if you could make a function to round the value up. So round 2.2 up to 3. Or a function to round down or round to nearest 5... etc. Would be helpful when I am calculating the required number of items required and get 2.2 back, I need it to be 3 when I cannot have a partial item.

Thanks!

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Jean Giraud  
#2 Posted : 23 May 2017 22:36:03(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Destory Go to Quoted Post
I was wondering if you could make a function to round the value up. So round 2.2 up to 3. Or a function to round down or round to nearest 5... etc. Would be helpful when I am calculating the required number of items required and get 2.2 back, I need it to be 3 when I cannot have a partial item.

Thanks!


How can maths invent that 2.2 could be/should be 5 ?
From the fx menu, scroll down to Ceil and plug your 2.2 in ... = 3
You could probably square the circle for 2.2 => 5
Offline csb531  
#3 Posted : 24 May 2017 00:10:52(UTC)
csb531


Rank: Member

Groups: Registered
Joined: 10/10/2012(UTC)
Posts: 24
Netherlands

Hello Destory,

Apart from the Ceil function, you can write your own function for this, i have made an example for you:
example

you can edit the function (extra if loop) if you want it to handle negative numbers differently.
ceil_and_roundup_to_5.sm (8kb) downloaded 427 time(s).

I hope this helps you.

regards,
csb

Edited by user 24 May 2017 00:14:45(UTC)  | Reason: sorry can't upload image?

Offline csb531  
#4 Posted : 24 May 2017 00:18:43(UTC)
csb531


Rank: Member

Groups: Registered
Joined: 10/10/2012(UTC)
Posts: 24
Netherlands

The image:
roundupto5.JPG

Offline Jean Giraud  
#5 Posted : 26 May 2017 04:43:25(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Here is the working program for n=5
A bit confusing for n ≠ 5

Jean

Utilities Matrix roundup_n.sm (11kb) downloaded 312 time(s).
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.