- Home
- Premium Memberships
- Lottery Results
- Forums
- Predictions
- Lottery Post Videos
- News
- Search Drawings
- Search Lottery Post
- Lottery Systems
- Lottery Charts
- Lottery Wheels
- Worldwide Jackpots
- Quick Picks
- On This Day in History
- Blogs
- Online Games
- Premium Features
- Contact Us
- Whitelist Lottery Post
- Rules
- Lottery Book Store
- Lottery Post Gift Shop
The time is now 8:34 am
You last visited
April 24, 2024, 11:56 pm
All times shown are
Eastern Time (GMT-5:00)
VB Shortcut for ceiling() function
Published:
For some reason, Visual Basic does not include a ceiling() function, which takes a fractional number, and gives you the next higher integer. For example:
- ceiling(1) = 1
- ceiling(1.7) = 2
- ceiling(1.1314) = 2
- ceiling(0.1) = 1
- ceiling(-1.1) = -1
And so on.
Well, I needed a ceiling() function this evening, so I figured out a very cool trick, without resorting to creating a new function. To get the ceiling of a number x, do this:
(-(int(-(x))))
The int() of a negative number returns the next lower number, not what you'd think, but perfect for our ceiling function. Then, just get the negative of that result. (I use all the parenthesis to make sure VB understands exactly what I'm trying to do.)
Comments
Post a Comment
Please Log In
To use this feature you must be logged into your Lottery Post account.
Not a member yet?
If you don't yet have a Lottery Post account, it's simple and free to create one! Just tap the Register button and after a quick process you'll be part of our lottery community.
Register