Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Function Int

Hi all,

I'm surprise by this result on excel( 2000, 2002, XP ) (win200, XP)

sub test()
Dim x as Long

x = Int(37.7266 * 10000)
' x = 377265
' I hope x = 377266

' but for :
x = int(37.7263 * 10000)
' I have x = 377263
end sub

In fact 37.7263 give expected result, 37.7264, no, 37.7265,
ok and so on...
Does somebody have an explanation ?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Function Int

Take out the Int stuff and it should be fine:

Sub test()
Dim x As Long

x = 37.7266 * 10000
' x = 377265
' I hope x = 377266

' but for :
x = 37.7263 * 10000
' I have x = 377263


--
-John Northwest11
Please rate when your question is answered to help us and others know what
is helpful.


"bcar" wrote:

Hi all,

I'm surprise by this result on excel( 2000, 2002, XP ) (win200, XP)

sub test()
Dim x as Long

x = Int(37.7266 * 10000)
' x = 377265
' I hope x = 377266

' but for :
x = int(37.7263 * 10000)
' I have x = 377263
end sub

In fact 37.7263 give expected result, 37.7264, no, 37.7265,
ok and so on...
Does somebody have an explanation ?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Function Int

John Bundy a écrit :
Take out the Int stuff and it should be fine:

Sub test()
Dim x As Long

x = 37.7266 * 10000
' x = 377265
' I hope x = 377266

' but for :
x = 37.7263 * 10000
' I have x = 377263


no because it's an expression and it's possible to have more than 4
decimals numbers.
the complete expression is :
x = y * 10000 - Int(y * 10000)
I know it's posssible to do x = y - round(y, 4) or to do :
tmp = y * 10000
x = tmp - Int(tmp)
The 2 solution work fine, but I don't want a solution, I'm surprised by
the result and I search an explanation

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Function Int

http://tinyurl.com/y4g5qg

or

http://tinyurl.com/wkmvr

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"bcar" wrote in message
...
John Bundy a écrit :
Take out the Int stuff and it should be fine:

Sub test()
Dim x As Long

x = 37.7266 * 10000
' x = 377265
' I hope x = 377266

' but for :
x = 37.7263 * 10000
' I have x = 377263


no because it's an expression and it's possible to have more than 4
decimals numbers.
the complete expression is :
x = y * 10000 - Int(y * 10000)
I know it's posssible to do x = y - round(y, 4) or to do :
tmp = y * 10000
x = tmp - Int(tmp)
The 2 solution work fine, but I don't want a solution, I'm surprised by
the result and I search an explanation

Thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy of excel file not showing formulal/function in the function b oaallam Excel Discussion (Misc queries) 4 September 6th 07 01:20 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 01:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"