Liberty BASIC Community Forum
« Math Floor and Ceiling Functions »

Welcome Guest. Please Login or Register.
Mar 29th, 2017, 04:19am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Math Floor and Ceiling Functions  (Read 216 times)
WJBeedle
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 24
xx Math Floor and Ceiling Functions
« Thread started on: Aug 23rd, 2016, 3:23pm »

Hi i don't see a Floor and Ceiling Functions in liberty basic.

did anyone ever make a code for it.
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1609
xx Re: Math Floor and Ceiling Functions
« Reply #1 on: Aug 23rd, 2016, 3:47pm »

I have them stored
Code:
print floor(3.5)
print ceil(3.5)
print floor(-3.5)
print ceil(-3.5)


'by uncleBen
function floor(x)
    floor = int(x)
    floor = floor - (x <> floor and x < 0)
end function

'--------------------------------------------------
function ceil(x)
    ceil = int(x)
    ceil = ceil + (x <> ceil and x > 0)
end function

 
User IP Logged

The existence of bug reports means somebody is using the software and actually cares to report back to you that he is having a problem with it, instead of just deleting it from their hard disk.
(Janusz Marcin Gorycki)
JackKelly
Guest
xx Re: Math Floor and Ceiling Functions
« Reply #2 on: Aug 23rd, 2016, 11:22pm »

What is a floor and a ceiling, and what are they used for!?? (in mathematics, that is...)
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1609
xx Re: Math Floor and Ceiling Functions
« Reply #3 on: Aug 24th, 2016, 02:09am »

Quote:
What is a floor and a ceiling, and what are they used for!?? (in mathematics, that is...)

It is restricted only by your imagination wink

wikipedia:Floor and ceiling functions

as for usage - (in programming) it's not uncommon to need things round UP (::ceil)
And if you use LB INT for rounding negative numbers, like in snap-to-grid code, you'll find some surprises. So you need floor.
« Last Edit: Aug 24th, 2016, 02:23am by tsh73 » User IP Logged

The existence of bug reports means somebody is using the software and actually cares to report back to you that he is having a problem with it, instead of just deleting it from their hard disk.
(Janusz Marcin Gorycki)
WJBeedle
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 24
xx Re: Math Floor and Ceiling Functions
« Reply #4 on: Aug 24th, 2016, 09:06am »

Thanks tsh73

where would i store this and do i need to add the function to a line of text.
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1609
xx Re: Math Floor and Ceiling Functions
« Reply #5 on: Aug 24th, 2016, 09:17am »

Quote:
where would i store this and do i need to add the function to a line of text.

It's simple BASIC, single source file, without libraries or INCLUDE files.
So you just save snippets of source code you like/might need - anythere - I just have folder "snippets", then if need copy/paste them.
There is some snippet managers but I didn't use them.

EDIT
so if you need "ceil" you just paste that function down your program and use it in the program like any other function.
« Last Edit: Aug 24th, 2016, 09:31am by tsh73 » User IP Logged

The existence of bug reports means somebody is using the software and actually cares to report back to you that he is having a problem with it, instead of just deleting it from their hard disk.
(Janusz Marcin Gorycki)
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls