BruceSteers
I was done the same, was used string functions. That's why you ask the question.
On the other hand, Cogier you have managed with your last reflection to make my neurons a mess. But what question are you asking?
Rounding to two decimal places without Round
- gambafeliz
- Posts: 141
- Joined: Friday 2nd September 2022 7:50pm
- Location: I live in the same city as Picasso
Re: Rounding to two decimal places without Round
For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you.
- cogier
- Site Admin
- Posts: 1126
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Rounding to two decimal places without Round
Sorry, I was not trying to fry your brain!On the other hand, Cogier you have managed with your last reflection to make my neurons a mess. But what question are you asking?
The purpose of Int is to create an Integer. So how can it return a Float?
The difference between Int() and CInt() is:
Int() may return a Float value, CInt() is limited to 32 bit Integer.
Int() rounds to the next lower value. i.e. -4.6 to -5, while CInt rounds towards 0 i.e. -4.6 to -4
Re: Rounding to two decimal places without Round
Uhmmm... perhaps the question should be put in Gambas "Mailing List".
Europaeus sum !
Amare memorentes atque deflentes ad mortem silenter labimur.
Amare memorentes atque deflentes ad mortem silenter labimur.
Re: Rounding to two decimal places without Round
Int() can return a float value because...
Dim fNum as Float
fNum=Int(1.234)
Print fNum
1.0000
whereas
Dim fNum as Float
fNum=CInt(1.234)
Print fNum
!@OUrg Expected float got Integer
What is misrepresented here is f(x) returns a value that can be interpreted as a variable on the left hand side of the assignment and therefor be a valid assignment.
Think this way, if fNum was a Float[] then you would not expect fNum=Int(1.234) to work but fnum=[Int(1.234)] should. There are many similar cases where the assignment could be misunderstood as being a nonnegotiable translation but in fact they are. One of the beauties of this is that an Object can in fact be anything so if the assignee is an object then the assignment can work.
Dim fNum as Float
fNum=Int(1.234)
Print fNum
1.0000
whereas
Dim fNum as Float
fNum=CInt(1.234)
Print fNum
!@OUrg Expected float got Integer
What is misrepresented here is f(x) returns a value that can be interpreted as a variable on the left hand side of the assignment and therefor be a valid assignment.
Think this way, if fNum was a Float[] then you would not expect fNum=Int(1.234) to work but fnum=[Int(1.234)] should. There are many similar cases where the assignment could be misunderstood as being a nonnegotiable translation but in fact they are. One of the beauties of this is that an Object can in fact be anything so if the assignee is an object then the assignment can work.
Have you ever noticed that software is never advertised using the adjective "spreadable".
- cogier
- Site Admin
- Posts: 1126
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Rounding to two decimal places without Round
I can't get my head around this. My brain hurts now.thatbruce wrote: ↑Monday 5th June 2023 11:42am
What is misrepresented here is f(x) returns a value that can be interpreted as a variable on the left hand side of the assignment and therefor be a valid assignment.
Think this way, if fNum was a Float[] then you would not expect fNum=Int(1.234) to work but fnum=[Int(1.234)] should. There are many similar cases where the assignment could be misunderstood as being a nonnegotiable translation but in fact they are. One of the beauties of this is that an Object can in fact be anything so if the assignee is an object then the assignment can work.