+24
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
while (!bFound && j < enmMessages)
{
if (!strcmp(str.operator const char * (), strPacketName[j]))
{
iPacketType = j;
bFound = true;
TRACE(" of type %s\n",strPacketName[j]);
strcat(strOut," of type ");
strcat(strOut, strPacketName[j]);
break;
}
j++;
}
guest,
19 Декабря 2008
+2.4
- 1
- 2
- 3
- 4
- 5
- 6
int a=0;
if (a != 0)
{
a=0;
}
else a=0;
guest,
15 Декабря 2008
+11.9
- 1
- 2
- 3
- 4
- 5
- 6
- 7
if ($site_is_work)
{
}
else
{
exit('Сайт не работает');
}
guest,
14 Декабря 2008
0
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
// https://github.com/dotnet/runtime/issues/117233#issuecomment-3028066225
// Issue: Math.Pow relies directly on the OS pow implementation
// Location: [src/coreclr/classlibnative/float/floatdouble.cpp lines 232‑236] and [src/coreclr/classlibnative/float/floatsingle.cpp lines 207‑211]
// COMDouble::Pow and COMSingle::Pow simply call pow/powf from the C runtime. On Windows 11 Insider Preview (build 27881.1000),
// these functions can return incorrect results (e.g., Math.Pow(-1, 2) giving -1). The JIT also uses these functions for constant folding, causing
// wrong constants to be embedded at compile time.
// Suggested Fix: Introduce a managed fallback in COMDouble::Pow/COMSingle::Pow that handles negative bases with integral exponents, bypassing the faulty system call.
//A simple approach:
FCIMPL2_VV(double, COMDouble::Pow, double x, double y)
{
FCALL_CONTRACT;
if ((x < 0.0) && (y == floor(y)))
{
double absResult = pow(-x, y);
return fmod(fabs(y), 2.0) == 1.0 ? -absResult : absResult;
}
return pow(x, y);
}
// Suggested Implementation:
// Add the following code to src/coreclr/classlibnative/float/floatdouble.cpp below line 234 before the return pow:
if ((x < 0.0) && (y == floor(y)))
{
double result = pow(-x, y);
if (fmod(fabs(y), 2.0) != 0.0)
{
result = -result;
}
return result;
}
// Add the following code to src/coreclr/classlibnative/float/floatsingle.cpp below line 209 before the return powf:
if ((x < 0.0f) && (y == floorf(y)))
{
float result = powf(-x, y);
if (fmodf(fabsf(y), 2.0f) != 0.0f)
{
result = -result;
}
return result;
}
// Add the following code to src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Math.cs below line 1124:
[Fact]
public static void Pow_NegativeBaseEvenExponent_ReturnsPositive()
{
Assert.Equal(1.0, Math.Pow(-1, 2));
Assert.Equal(16.0, Math.Pow(-2, 4));
}
Вот к чему плавучий петух приводит!
j123123,
04 Июля 2025
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
/* Python:
def A004086(n):
return int(str(n)[::-1])
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int A004086(int n) {
char str[12]; // Enough to hold the string representation of an int
sprintf(str, "%d", n);
int len = strlen(str);
char reversed[12];
for (int i = 0; i < len; i++) {
reversed[i] = str[len - 1 - i];
}
reversed[len] = '\0'; // Null-terminate the string
return atoi(reversed);
}
Результат переписывание с "Python" на "C". A004086 это последовательность из OEIS https://oeis.org/A004086
j123123,
02 Января 2025
−2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.zip.*;
import java.io.*;
public class CitiesPrinter {
public static void main(String[] args) throws IOException {
final String fileName = "/storage/emulated/0/Documents/Jvdroid/single-files/_данные_Сбер_Java_20210407090226.zip";
try(ZipInputStream unzipping = new ZipInputStream(new FileInputStream(fileName)));
{
ZipEntry entry = null;
String name = null;
long size = 0;
while((entry=unzipping.getNextEntry())!= null) {
name = entry.getName();
size = entry.getSize();
System.out.println("FileName: " + name + "FileSize: " + size);
FileOutputStream unzippedFile = new FileOutputStream("/storage/emulated/0/Documents/Jvdroid/single-files/new" + name);
for (int c = unzipping.read(); c != -1; c = unzipping.read()) {
unzippedFile.write(c);
}
unzippedFile.flush();
unzipping.closeEntry();
unzippedFile.close();
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
Path path = Paths.get(fileName);
Scanner scanner = new Scanner(path);
scanner.useDelimiter(System.getProperty("line.separator"));
while(scanner.hasNext()){
System.out.println("Строка: " + scanner.next());
}
scanner.close();
scanner = new Scanner(Paths.get("/storage/emulated/0/Documents/Jvdroid/single-files/_данные_Сбер_Java_20210407090226.zip/city_ru.csv"));
scanner.useDelimiter(System.getProperty("line.separator"));
while(scanner.hasNext()){
Employee emp = parseCSVLine(scanner.next());
System.out.println(emp.toString());
}
scanner.close();
scanner = new Scanner(System.in);
System.out.println("Вводим первое слово: " + scanner.next());
}
private static Employee parseCSVLine(String line) {
Scanner scanner = new Scanner(line);
scanner.useDelimiter("\\s*,\\s*");
String name = scanner.next();
int age = scanner.nextInt();
String gender = scanner.next();
CitiesPrinter jfs = new CitiesPrinter();
return jfs.new Employee(name, age, gender);
}
}
class Employee{
private String name;
private int age;
private String gender;
public Employee(String n, int a, String gen){
this.name = n;
this.age = a;
this.gender = gen;
}
@Override
public String toString(){
return "Name=" + this.name + "::Age=" + this.age + "::Gender=" + this.gender;
}
}
Что не так?
sbnet,
09 Февраля 2023
0
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
const newRecords = {}
for (const prop in overridenRecords) {
if(Object.prototype.hasOwnProperty.call(overridenRecords, prop)) {
const source = Object.values(allRecords).find((record) => record.id == prop)
newRecords[prop] = {...overridenRecords[prop], ...source}
}
}
return newRecords
bootcamp_dropout,
17 Декабря 2022
+5
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
// Heap memory allocate function (must not be used!)
caddr_t _sbrk(int incr) {
<...>
void some_bastard_called_sbrk();
some_bastard_called_sbrk(); // Produce linker error in case it is used
}
_ATTRIBUTE ((__format__ (__printf__, 1, 2)))
int printf (const char *__restrict format, ...)
{
<маленький трехколесный велосипед>
}
int putchar(int c)
{
<...>
}
int puts(const char *s)
{
<...>
}
_ATTRIBUTE ((__format__ (__printf__, 2, 3)))
int sprintf (char *__restrict s, const char *__restrict format, ...)
{
<...>
}
STM32. Я просто хочу использовать printf для вывода в последовательный порт и не течь. Ведь для этого нужно только реализовать int _write(int file, char *data, int len) и всё. Ой, а почему иногда программа падает где-то в кишках рантайма?
Может, стек переполняется? Да нет, проверил, значения в норме...
Просто стандартная библиотека от ST - это не курсовая ардуинщика, тут все системно, хендлы потоков, дескрипторы устройств и управляющие структуры. При первом обращении printf (и sprintf тоже!) выделяет себе в куче около 400 байт. Замечательное решение, помогающее сэкономить память, если мы не используем стандартный вывод! А куча тут - это просто последовательно заполняемая область памяти, размеры которой задаются в linker script (я вообще 0 указал, я ведь не использую malloc). Проверять выход за пределы кучи мы, конечно, не будем - зачем, когда рядом такая замечательная, никому не нужная область стека.
Да, и если забыть отключить буферизацию setvbuf(stdin/stdout/stderr, NULL, _IONBF, 0); , то он выделит не 400 байт, а килобайт (на контроллере с 8K RAM).
В общем, ах, оставьте меня, сам все напишу.
Только надо еще putchar и puts реализовать, а то компилятор любит printf'ы оптимизировать. И не забыть, что puts добавляет перевод строки. Уф, вроде все.
Steve_Brown,
05 Августа 2022
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
<?php defined('SYSPATH') or die('No direct script access.');
/*
* Базовый класс главной страницы
*/
class Controller_Index extends Controller {
public function before() {
parent::before();
I18n::lang('ru');
$settings = Kohana::config('settings');
Cookie::$salt = 'asd12d2';
Session::$default = 'cookie';
$this->session = Session::instance();
}
public function action_index() {
//Путь до файла первоночального xml (xsl)
$path_xml='tpl/xml.xsl';
//Путь конечного xsl
$path_xsl='tpl/index.xsl';
$url = $this->request->param('stuff');
//print_r($_SERVER);
/*if($_SERVER ['REQUEST_URI']=='/'){
$this->request->redirect($_SERVER ['HTTP_X_FORWARDED_PROTO'].'://'.$_SERVER['HTTP_HOST'],'301');
}*/
if(empty($url)){
$url='/';
}
$htmlfile='cache-html/'.md5($url);
$allurl=$_SERVER ['REQUEST_URI'];
if($allurl=='/20-40-kvm') $this->request->redirect('/sadovye-domiki','301');
if($allurl=='/40-80-kvm') $this->request->redirect('/sadovye-domiki','301');
if($allurl=='/80-i-bolee-kvm') $this->request->redirect('/sadovye-domiki','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=0&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/sadovye-domiki','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=1&technology%5B%5D=0&technology%5B%5D=1&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=81-400') $this->request->redirect('/80-i-bolee-kvm','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=1&technology%5B%5D=0&technology%5B%5D=1&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=40-80') $this->request->redirect('/40-80-kvm','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&technology%5B%5D=0&technology%5B%5D=1&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/stroitelstvo-dachnyh-domov','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=2&technology%5B%5D=0&technology%5B%5D=1&technology%5B%5D=2&technology%5B%5D=3&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/kottedzhi','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=3&technology%5B%5D=0&technology%5B%5D=2&technology%5B%5D=3&floors%5B%5D=1&floors%5B%5D=1.5&price=0-3000000&area=0-400') $this->request->redirect('/bani','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=3&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&price=0-3000000&area=0-400') $this->request->redirect('/bani-iz-profilirovannogo-brusa','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=3&technology%5B%5D=0&floors%5B%5D=1&floors%5B%5D=1.5&price=0-3000000&area=0-400') $this->request->redirect('/karkasnye-bani','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=3&technology%5B%5D=3&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/bani-iz-ocilindrovannogo-brevna','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=316018-3000000&area=0-400') $this->request->redirect('/brus','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=2&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/kottedzhi-profilirovannyj-brus','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=0&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=329056-3000000&area=0-400') $this->request->redirect('/dachnye-doma-karkasnaya-tehnologiya','301');
if($allurl=='/nashi-proecty?searcher=48291§ion=3924&destination%5B%5D=0&destination%5B%5D=1&destination%5B%5D=2&technology%5B%5D=1&floors%5B%5D=1&floors%5B%5D=1.5&floors%5B%5D=2&price=0-3000000&area=0-400') $this->request->redirect('/individualnye-proekty','301');
Там ещё дальше веселье продолжается, но гк не дает запостить больше
YpaHeLI_,
02 Апреля 2022
0
- 1
Борманд, у тебя спина рыжая!
Ха-ха, я пошутил, с первым апреля )))
JloJle4Ka,
01 Апреля 2022