Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Oct 14, 2019 5:35 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: converting VB Int() to RB
PostPosted: Tue Nov 22, 2011 3:42 pm 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
I have a VBfunction i am converting which uses this....basically does not round but return just integer part of a number....

I have looked in documentation but am not sure...is the equivalent the Floor function?

_________________
Currently using:
Windows XP Pro SP3
Real Studio 2011 Release 4.3 Enterprise
and
Mac OS 10.7.4
Real Studio 2011 Release 4.3 Enterprise
(finally also compiled on Mac)


Top
 Profile  
Reply with quote  
 Post subject: Re: converting VB Int() to RB
PostPosted: Tue Nov 22, 2011 5:08 pm 
Offline
User avatar

Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1855
Location: Michigan, USA
Yup. :)

Floor rounds down (ignoring all but the integer, as it were); ceiling rounds up invariably.

_________________
Windows 8 x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2012r1.1

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton


Top
 Profile  
Reply with quote  
 Post subject: Re: converting VB Int() to RB
PostPosted: Thu Nov 24, 2011 5:40 am 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
You don't need floor in this instance.
Dim mvar as double = 3.14
dim mInt as integer = mvar

MInt now equals 3

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: converting VB Int() to RB
PostPosted: Fri Nov 25, 2011 9:46 am 
Offline
User avatar

Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1855
Location: Michigan, USA
I'm sure it's unnecessary, but I tend not to trust myself to such conversions. It wouldn't surprise me if — say in the switch to LLVM — the conversion altered from an implicit floor, to rounding. Albeit, I'm sure there's a convention for this, but I like to be safe and explicit.

But, I'm starting to delve in to development preferences. ;)

_________________
Windows 8 x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2012r1.1

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult and not tried." - G.K. Chesterton


Top
 Profile  
Reply with quote  
 Post subject: Re: converting VB Int() to RB
PostPosted: Thu Jan 26, 2012 4:12 pm 
Offline

Joined: Sat Mar 25, 2006 7:29 am
Posts: 120
Sure you need to use Floor() because Int() in VB delivers the greatest whole number that is smaller than the float-value that is within it's brackets.
In RB:
dim mint as integer = 3.14 gives as result 3
and for negative values:
dim mint as integer = -3.14 gives as result -3

but in VB:
Int(3.14) gives as result 3 (this is equal to the result in RB)
Int(-3.14) gives as result -4 (instead of -3 in RB)

Using Floor(mint) gives the same results in RB as Int(mint) in VB.

Best regards,
Andre


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group