Hi
I am using the base_convert() function to convert numbers between binary,
hexadecimal, decimal, etc... It works great, but I have problems converting
numbers with .'s
Like this number:
15.20 decimal will be 1111 as binary...
is there any way to include the rest of the number in the convertion? 2 3228
"Sverre Bakke" <sv************ *****@ingen-spam.online.no> wrote
in message news:<bn******* ***@dolly.unine tt.no>... I am using the base_convert() function to convert numbers between binary, hexadecimal, decimal, etc... It works great, but I have problems converting numbers with .'s
Like this number:
15.20 decimal will be 1111 as binary...
is there any way to include the rest of the number in the convertion?
Sure, just write your own conversion function. Note, however, that
you won't be able to use those binary, octal, or hexadecimal floats
anywhere; PHP only recognizes binary, octal, and hexadecimal integers.
Cheers,
NC
I don't think base_convert caters for floating point binary numbers,
which is a little silly, so you'll have a to write a function to do that
for you. I suggest you type cast it to a string, use the dot to divide
the string into two, and then convert each number into binary, and then
do some floating point arithmetic to get the true result. If somebody
would like to post such a function? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mariusz Sakowski |
last post by:
I'm writing class which will be able to store large numbers (my
ambition is to make it able to operand on thousands of bits) and
perform various operations on it (similiar to those available with int
type). I want to store the number as binary stream, and I don't know
how to convert large decimal string (char*) to binary stream.
Converting using MOD would last for hours with really big numbers, and
in fact I don't know any other ways to...
|
by: Benjamin Rutt |
last post by:
Does anyone have C code laying around to do this?
I have to read in some binary data files that contains some 4-byte
IBM/370 floating point values. I would like a function to convert
4-byte IBM/370 float values into IEEE 754 'float' values that I can
use directly with any modern C environment (that uses IEEE 754).
I can handle endian conversion myself (the files are stored as big
endian, and I'll process them on a little endian...
|
by: sal |
last post by:
Greets, All
Converting array formula to work with datatables/dataset tia sal
I finally completed a formula I was working on, see working code below.
I would like to change this code so it will work with a variable mutl-
row, 5 column datatable where the users select items. Anyone have any
suggestions on where to start?
Or changes in the current code that might be made.
|
by: zexpe |
last post by:
I have an extremely cpu/data intensive piece of code that makes heavy
use of the following function:
void convertToDouble(const std::string& in, double& out)
{
out = atof(in.c_str());
}
I would really like to get away from using any old C-style functions.
So, I modified the above function to make it follow the C++ convention:
|
by: Tor Aadnevik |
last post by:
Hi,
I have a problem converting values from Single to double.
eg. When the Single value 12.19 is converted to double, the result is
12.1899995803833.
Anyone know how to avoid this?
Regards Totto
| |
by: jaks.maths |
last post by:
How to convert negative integer to hexadecimal or octal number?
Ex: -568
What is the equivalent hexadecimal and octal number??
|
by: jim |
last post by:
Does anyone know why the query below would return numbers? I'm
attempting to produce a report that shows in *one* column the names
that appear in multiple columns in a single table.
Table Name: project
col1 = project_id
col2 = manager
col3 = participant1
col4 = participant 2
col5 = participant 3
|
by: Terry Reedy |
last post by:
A. Joseph wrote:
These are number representation systems that can be applied to or used
with integral, rational (numberator,denominator), and 'point' numbers.
Try Wikipedia or any search engine.
There are standard algorithms for converting between representations.
See above. Good programmer calculators have these built in.
|
by: raylopez99 |
last post by:
Here is a short program demonstrating using IEnumberable, Linq,
predicates, extension methods and some tricks and how to convert an
IEnumberable sequence into an array.
For future reference, not intended as a question.
RL
Main():
int numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11};
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |