Skip to content

YlmzCmlttn

Cemalettin Yılmaz Blog

Menu
  • Home
  • About Me
  • Projects
    • Iot-AR
    • Magnifi-AR
    • Smarthome-IOS
    • Others
  • Categories
    • Articles
    • Augmented Reality
    • Capture The Flag
      • Google CTF
        • 2018
    • Embedded Systems
    • IoT
    • Logisim
    • My Essays
    • Nvidia Jetson
      • Jetson TX1
    • Operating Systems
      • Kali
      • Raspbian
      • Ubuntu
    • Personal
    • Programming
      • Arduino
      • C
      • C#
      • Css
      • Html
      • Js
      • Matlab
      • Node.js
      • Python
      • Swift
      • VHDL
    • Projects
      • Embedded Systems
      • Electric
      • IoT
      • IoT-AR
      • Logisim
      • Magnifi-AR
      • Pose Estimation
    • Raspberry Pi
    • Xilinx
    • Others
Menu

Category: C++

atof stof stod problems with local floating point separator in C/C++

Posted on May 7, 2021 by Yılmaz Cemalettin

Today I encounter a problem with my C++ code. I try to convert string to double. Then I realize in my computer std::atof doesn’t work properly. Also others(stof stod) doesn’t not work correctly. Then I decide to find the issue. I write to simple script to print all output of those functions.

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//
#include <iostream>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    std::string num = "3.5";
    std::cout<<num<<std::endl;
 
    double ret = std::atof(num.c_str());
    std::cout<<ret<<std::endl;
    std::cout<<ret+0.1<<std::endl;
 
    ret = std::stof(num);
    std::cout<<ret<<std::endl;
    std::cout<<ret+0.1<<std::endl;
 
    ret = std::stod(num);
    std::cout<<ret<<std::endl;
    std::cout<<ret+0.1<<std::endl;
    
    return 0;
 
}

Outputs:

1
2
3
4
5
6
7
8
//
3.5
3
3.1
3
3.1
3
3.1

…

Read more

Introduction OpenCV | Learning OpenCV3 C++

Posted on March 17, 2019March 17, 2019 by Yılmaz Cemalettin

This post series is the Solutions of the Learning OpenCV 3 written by Adrian Kaehler & Gary Bradski Chapter 2: Introduction OpenCV For this chapter, I prepare Cmake file to build the example code

Read more

Install OpenCV | Learning OpenCV3 C++

Posted on March 17, 2019 by Yılmaz Cemalettin

This post series is the Solutions of the Learning OpenCV 3 written by Adrian Kaehler & Gary Bradski Chapter 1: Overview In this chapter shows how to install OpenCV in your computer. I use Ubuntu OS, so that I write a shell script for the installing OpenCV you can use it easily.  

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install build-essential -y
sudo apt-get install cmake -y
sudo apt-get install libopenblas-dev -y
sudo apt-get install git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev -y
sudo apt-get install libboost-all-dev -y
sudo apt-get install libncurses5-dev libncursesw5-dev -y
wget https://github.com/opencv/opencv/archive/3.4.0.zip
unzip 3.4.0.zip
cd opencv-3.4.0
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j8
sudo make install
sudo apt-get install libboost-all-dev

Libraries

Read more

Writing a Program | C++

Posted on March 17, 2019March 17, 2019 by Yılmaz Cemalettin

This post series is the Solutions of the Programming — Principles and Practice Using C++ (Second Edition) written by Bjarne Stroustrup Chapter 6: Writing a Program Drill

Read more

Nature of Lights | Optics C++

Posted on February 10, 2019March 17, 2019 by Yılmaz Cemalettin

These post series aim to solve examples and problems from Introduction to Optics book which is writen by Frank L. Pedrotti, Leno M. Pedrotti and Leno S. Pedrotti. Chapter 1: Nature of Lights Example 1 An electron is accelerated to a kinetic energy Ek of 2.5 MeV. (a) Determine its relativistic momentum, de Broglie wavelength, and speed. (b)…

Read more

My Motto

“Learn to share, Share to learn”

LinkedIn Badge

Cemalettin Yılmaz

Ads

Archives

Categories

  • Articles (1)
  • Augmented Reality (3)
  • Capture The Flag (23)
    • Google CTF (22)
      • 2018 (13)
      • 2019 (9)
    • PicoCTF (1)
      • 2019 (1)
  • Embedded Systems (3)
  • IoT (3)
  • Logisim (1)
  • My Essays (3)
  • Nvidia Jetson (5)
    • Xavier (5)
  • Operating Systems (24)
    • Kali (3)
    • Raspbian (2)
    • Ubuntu (21)
  • Others (1)
  • Personal (1)
  • Programming (44)
    • Arduino (4)
    • C (10)
    • C# (4)
    • C++ (5)
    • Css (1)
    • CUDA (6)
    • Html (1)
    • Js (2)
    • Libraries (5)
      • OpenCV (3)
      • OpenGL (2)
    • Matlab (14)
    • Node.js (5)
    • Python (6)
    • Swift (3)
  • Programs (4)
    • Tools (4)
  • Projects (21)
    • Books Solutions (8)
    • Electric (2)
    • Embedded Systems (2)
    • Energy Harvesting (1)
    • IoT (2)
    • IoT-AR (1)
    • Logisim (1)
    • Magnifi-AR (3)
    • Pose Estimation (3)
    • Smarthome-Ios (1)
  • Raspberry Pi (3)
  • Uncategorized (2)
  • YZlib (1)

Recent Posts

  • atof stof stod problems with local floating point separator in C/C++
  • Pico CTF 2019 Answers
  • YZlib: Personal C++ Library
  • Drive to target | Google CTF 2019
  • FriendSpaceBookPlusAllAccessRedPremium | Google CTF 2019

Recent Comments

  • AbaShelha on Ghidra Installation on Ubuntu |18.04, 16.04, 14.04
  • Peter on Ghidra Installation on Ubuntu |18.04, 16.04, 14.04
  • Yılmaz Cemalettin on Ghidra Installation on Ubuntu |18.04, 16.04, 14.04
  • Yılmaz Cemalettin on 16-Bit CPU on Logisim
  • Jenny on 16-Bit CPU on Logisim
  • MOON on 16-Bit CPU on Logisim
  • anti on Ghidra Installation on Ubuntu |18.04, 16.04, 14.04
  • hunkerjr on STOP GAN | Google CTF 2019
  • Shaq on 16-Bit CPU on Logisim
  • NURUL AFIQAH MOHD HASBULLAH on 16-Bit CPU on Logisim

Linkedln

© 2022 YlmzCmlttn | Powered by Superbs Personal Blog theme