Programming :: C Function To Reverse The Byte Order In A Double?
Aug 12, 2010
I'm trying to write an extension to PHP which means coding in C. I'm really really rusty at C coding and was never very good at it.
Can anyone propose an efficient, safe, and [hopefully] future-proof way of reversing a double? Keep in mind that it should work on as many systems as possible and on 32- and 64-bit systems (and on ???-bit systems in the future?). Will the size of a 'double' ever change or will it always be 8 bytes?
I've tried this and it doesn't work...the compiler complains about "invalid operands to binary" because I'm trying bitwise shiftw on a non-integer.
Code:
x = (x>>56) |
((x<<40) & 0x00FF000000000000) |
((x<<24) & 0x0000FF0000000000) |
((x<<8) & 0x000000FF00000000) |
[Code]....
View 3 Replies
ADVERTISEMENT
Apr 27, 2009
Here is what I have so far.The program receives and echos characters without syscalls. I am trying to add 2 procedures(rev7 and putint)Rev7: Reverses the least significant 7 bits and outputs $s2Putint: Prints the decimal value of $s2.When i run it, it echos the character then prints a "P". I have no idea where that comes from.Everything seems correct to me but I do not understand why it does not print the decimal digits
Code:
.data
hello:.asciiz "Enjoy This Program
[code]....
View 2 Replies
View Related
Jul 6, 2011
I got across a peculiar problem with memcpy.History:writing a code which do flash/Read functionality for SPI Parts.
Implementation:
1.memory map the Flash chip registers to userspace. - fine
2.Issue block read command
3.Just print the data I got, using the memory mapped address - fine I got the correct data.
4.Copy the data to a local buffer from memory mapped address using memcpy - FAIL
UPDATE:
on SUSE 11.3 -32 bit the above code worked perfectly, but on SUSE 11.4 - 64bit , Ubantu, Fedora it failed.
I am using gcc compiler obviously. I am using i386/x86_64 OS. Processor: Intel core 2 duo, SNB after step 4 , when I dump the data from local buffer every thing is FF.But step 4, if i implement byte by byte copy using assignment operator, it worked.is there any known bug with memcpy? am I missing anything?
View 7 Replies
View Related
May 8, 2010
I have a BROTHER MFC-495cw and i do alot of printing so when i as openoffice, adobe etc to print a document it always comes out 1st page first with the last page on top (when i do it this way i have to go in and turn everything around i'm tired of doing that) i want it to print the page from last to first that way the first page is always on the top of the stack
i am running ubuntu karmik koala and i already mentioned my printer model
View 4 Replies
View Related
May 9, 2010
Well I'm new on linux and I want to install
libqt4-core
libqt4-dev
libqt4-gui
libqt4-sql
Qt4-Dessing
but I dont find it on any repository, try to manually install but give me an error" The system byte order could not be detected! " is there any other way to install those programs?
Opensuse 11.2 (x86_64)
View 2 Replies
View Related
May 26, 2011
I am running fully updated ubuntu 10.10 and now, since 2 days ago, when I open a file
in open office, gimp or gedit etc the directories and files now appear in reverse alphabetical order.
View 8 Replies
View Related
Apr 6, 2011
I'm curious as to whether anyone else has experienced this, and has an explanation. I'm running Kile 2.0.85 under openSUSE 11.3 32-bit on a Lenovo X61. Twice in the past couple of days I've had the bizarre experience that, upon a sudden burst of typing my text has appeared in Kile in reverse order.
no ngis fo ecnacifingis eht fo redaer eht dnimer esaelp ,dniw cihportsoeG a htiw snoitalumis eht gnicudortni erehw ,Note the perfect reversal (I rarely type that accurately in forward mode). A day later it happened again: )1.3.5( noitceS fo hpargarap dnoces eht ni ,niaga ecnO.I've been using Kile for almost a year now, on two different machines and under several versions of openSUSE. Nothing remotely like this has happened before. I don't think I have a virus. I can't think of any event that may have heralded this mystical behaviour. Cheers, jdw
View 2 Replies
View Related
Mar 19, 2011
I used to use ubuntu studio, which when you double clicked on the bar at the top of a window it would slide in under itself. I had to reinstall so I downloaded the Ubuntu 10.10 alt CD, but now double clicking maximizes, how do I change it back.
View 2 Replies
View Related
May 17, 2011
The top row of keys on my notebook are currently assigned to various media functions (brightness, volume, play, stop, etc.) These keys are rarely used, and it would be better if they were assigned to the function keys (f1,f2,f3,...) by default, rather then using the fn key to access them. Locking the fn key down is not an option. What can I do?
View 2 Replies
View Related
Nov 24, 2010
I'm learning C and trying to write a program to convert gigabyte into byte. It will take 50% of the value given and then convert that value into byte. But the problem is the output goes into minus / negative value. Like, if I enter 22, I get output: -2147483648.
Code:
#include <stdio.h>
#include <math.h>
main (int argc, char* argv[])
{
[Code]....
View 5 Replies
View Related
Jul 10, 2011
As 2.17
I want to code this:
and byte[45],03
In words, AND the byte at memory location 45 with immediate value 03. As reports "Ambiguous operand size for and". How could I code the instruction such that as understands my intention?
john: .byte 45
and byte[john],03
gives the same error.
View 8 Replies
View Related
Jun 11, 2010
E.g. 98 is represented as 1100010 (number of valid bits is 7)
What is the formula to calculate the number of valid bits in a byte ?
View 14 Replies
View Related
Nov 16, 2010
Code:
#include <iostream>
using namespace std;
[code]...
View 1 Replies
View Related
May 18, 2010
I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.
View 2 Replies
View Related
Oct 26, 2010
I need to convert an integer to a byte array of size 2 and vice versa. The code shown below works well for positive values but not for negative values. Also, using an array of size four makes the conversion works. However, I am limited to an array of size 2.
View 5 Replies
View Related
Jun 16, 2010
I am trying to learn assembly using nasm as assembler. I did not found example related to string operation. I had following example code,
global asm_strlen
section .data
section .bss
section .text
[code].....
my problem is at highlighted line, I am not getting how to copy a byte into 4 byte reg. rather what is syntax of mov instruction to mov byte to WORD DWORD etc.
View 3 Replies
View Related
Jan 11, 2013
Assuming there are two list objects a1, a2.
a1 = ['
']
a2 =['hi
']
len() built-in function gives total number of elements in the list object.
len(a1) gives 1. len(a2) gives 1 also.
Code: Select all$ python
Python 2.7.3 (default, SepĀ 9 2012, 17:41:34)
[GCC 4.7.1] on linux2
[Code]......
I thought there exists a built-in function that gives total size of a list object in byte. So using the function produces 1 for a1, 3 for a2. I haven't found such function or module yet.
View 3 Replies
View Related
Dec 13, 2009
I wrote a serial port communication program to access a equipment.
int main(void)
{
int fd = 0;
int nread = 0,i = 0,nwrite = 0, tmpread = 0, m = 0, n = 0 ;
[code]....
View 2 Replies
View Related
Jun 6, 2010
In bash I need to use some equivalent of double quotes inside double quotes (or the other way around.)I need to run the following statement to get the output of foo and store it in a variable while passing foo the $file which probably contains spaces.
Code:
variable=$(foo "$file")
The problem is that foo might return an empty string and if it does I need to catch it
[code]...
View 6 Replies
View Related
May 24, 2010
I want to declare a function in a function, but had no success till now, see the error code below and visit the project at sourceforge
[Code]...
View 14 Replies
View Related
Jun 20, 2010
I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.
#!/bin/bash
addelementtoarray()
{
local arrayname=$1
[code]....
View 10 Replies
View Related
Sep 27, 2009
Reverse dns lookup in C?
View 3 Replies
View Related
Oct 12, 2009
I am using RHEL5. These are my config files:
Code:
options {
listen-on port 53 { 127.0.0.1; 192.168.14.54; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
[code]....
View 3 Replies
View Related
Sep 22, 2010
I am making a program to reverse a string
Code:
#include<stdio.h>
int main ()
{
int i,j;
[Code].....
View 5 Replies
View Related
Aug 23, 2010
QTreeView and QTableView have sort functions, but I need to sort a QListView, and for there to be no way for the user to turn off or reverse sorting.
View 11 Replies
View Related
Apr 5, 2010
Someone know how i can convert from hex string to double in c/c++?? Example 40668472B020C49C is 180.139
reference page: http://babbage.cs.qc.edu/IEEE-754/64bit.html
View 10 Replies
View Related
Mar 6, 2010
I need to generate random numbers using /dev/random in C. The numbers should be of type double (64-bit floating point).The functionality should be equal to linux command "od -An -N8 -t fD /dev/random", but written in C.The prototype should be "double drand(void);".
View 7 Replies
View Related
Aug 25, 2010
how to use socket programming in order to implement chatting feature
View 5 Replies
View Related
Nov 4, 2010
I'm trying to write a bash script that has to extract values from a csv file. Problem is there are lines like this:a,b,c,"dd,dd,dd",e,f,gI'm using awk to extract the values but when I try it extract value 4 with awk I get:"ddinstead of:"dd,dd,dd"Does anyone know how to get awk to ignore commas within double quotes?
View 5 Replies
View Related
Nov 23, 2010
in c/c++, double is usually 8 bytes. It has a 52-bit mantissa (or significand, or base), an 11-bit exponent, and a 1-bit sign. My question is: is the mantissa a 52-bit integer? Or is the decimal point just after the first bit. Meaning: if the mantissa was 1000110011100011 (in binary) would that make the value of the mantissa (assuming the exponent was 0) 1000110011100011, or 1.000110011100011? (in binary)
View 1 Replies
View Related