473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

C# equivalent question

I am trying to convert a VB6 app into C# and I cannot find an equivalent to
VB6's Fix Function. Does anyone know if there is one or how to get around
it?

Thanks
Nov 15 '05 #1
4 7981
Forgot to say I do not want to include VB.Net Runtime and use:
Microsoft.VisualBasic.Conversion.Fix

Thanks

"Same" <s> wrote in message news:O3**************@TK2MSFTNGP09.phx.gbl...
I am trying to convert a VB6 app into C# and I cannot find an equivalent to VB6's Fix Function. Does anyone know if there is one or how to get around
it?

Thanks

Nov 15 '05 #2
Same,
Have you looked at the System.Math class?

Specifically Math.Floor & Math.Ceiling?

Math.Floor matches Fix, however you may want to use Math.Ceiling if you have
negative numbers...

Hope this helps
Jay

"Same" <s> wrote in message news:O3**************@TK2MSFTNGP09.phx.gbl...
I am trying to convert a VB6 app into C# and I cannot find an equivalent to VB6's Fix Function. Does anyone know if there is one or how to get around
it?

Thanks

Nov 15 '05 #3
"Same" <s> wrote:
I am trying to convert a VB6 app into C# and I cannot find an equivalent to
VB6's Fix Function. Does anyone know if there is one or how to get around
it?

Thanks


I think you are looking Math.Ceiling
(However did they came up with "Fix" in VB I don't know...
somebody must have skipped math class)
Nov 15 '05 #4
"Same" <s> wrote:
I am trying to convert a VB6 app into C# and I cannot find an equivalent to
VB6's Fix Function. Does anyone know if there is one or how to get around
it?

Thanks


Posted in haste...

Actually the MSDN defines Fix(number) = Sign(number) * Int(Abs(number))
I think the following is equivalent

(x >= 0 ? Math.Floor(x) : Math.Ceiling(x))
there may be a better way to replace it though.

Watch out for "rounding" errors.

The MSDN Math.Floor sample shows:

Floor(1.00) = 0

because after 11 subtractions of 0.1 from 2.1 "value" ends up with a number slightly less than 1.0

If you set "value" to exactly 1.0 you get the following result
Floor(1.00) = 1
Decimal.Trunctate may also be worth a look

Returns the integral digits of the specified Decimal; any fractional digits are discarded.
Return Value: The Decimal result of d rounded toward zero, to the nearest whole number.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
16
by: jonathan cano | last post by:
QUESTION: In practice, lines 36 and 37 below are usually equivalent to the default copy constructor (.e.g line 33). My questions are: (a) Does ISO 14882 guarantee that lines 36 and 37 are...
8
by: TogaKangaroo | last post by:
A question I'm sure has come up before, but does anyone know how to write/where to find the std for the equivalent of the normalpdf(X, mu, sigma) function in matlab? For anyone who does not know...
4
by: Alan | last post by:
Is anyone know the equivalent term used for Dynamic Link Library (DLL) in unix environment?? Thanks Alan
9
by: Paul Brownjohn | last post by:
Hello I am new both to this group and to C# programming having spent the last 15 years or so writing C and VB. You will forgive I hope if I am asking the totally obvious but it is a question...
11
by: Randy | last post by:
What is C++'s equivalent of ISO C99's stdint.h? --RY
35
by: lnatz | last post by:
Hi, Is there an equivalent to the perl command chomp in C? And if there is no exact equivalent command, how would I go about removing the "\n" at the end of a stdin? Thank you, Natalie
5
by: =?Utf-8?B?VG9tYXM=?= | last post by:
Hello, Somebody knows which is the equivalent one in C++/CLI ? HINSTANCE ShellExecute(HWND hwnd, LPCTSTR lpOperation, LPCTSTR lpFile, LPCTSTR lpParameters, LPCTSTR lpDirectory, INT nShowCmd
18
by: Csaba Gabor | last post by:
Is there a straightforward way of implementing a PHP equivalent to window.setTimeout? In a javascript web app, it's often the case that things are done on an event driven basis. For example,...
6
by: mearvk | last post by:
Does C++ or C have something roughly equivalent to this: http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html What I need is a way to quickly convert between decimal and binary and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.